状态错误。 Angular JS

时间:2018-04-21 09:14:44

标签: angularjs state

我有一项任务要合并到Angular中state.js中的组件。我是新手。我已经包含了代码,它正在抛出状态错误,我无法理解它的来源。我认为我做得不对,但缺少一些我无法理解的东西。

这是错误: -

error: Could not resolve 'auth.app' from state 'auth'
    at Object.x.transitionTo (angular-ui-router.min.js:7)
    at Object.x.go (angular-ui-router.min.js:7)
    at angular-ui-router.min.js:7
    at angular.js:16299
    at e (angular.js:4924)
    at angular.js:5312

我也经历过其他答案,但找不到我的解决方案。 my state.js: -

app.config(['$stateProvider', '$urlRouterProvider',
        function ($stateProvider, $urlRouterProvider) {

       $urlRouterProvider
                .when('/home', '/')
                .otherwise('/');
       $stateProvider
// Applications (parent state)
                .state('auth.apps', {
                    abstract: true,
                    url: '/applications',
                    template: '<div ui-view autoscroll="false" class="mainView-animate"></div>',
                    ncyBreadcrumb: {
                        label: 'Applications'
                    }
                })
                // Applications childs
                .state("auth.apps.view", {
                    // this state page title
                    page_title: 'New - Applications',
                    // this state url
                    url: "/apps",
                    templateUrl: 'views/externals/apps.html',
                    // load state specific js/css
                    resolve: {
                        files: [
                            'uiLoad',
                            function (uiLoad) {
                                return uiLoad.load([
                                    // c3 charts
                                    'assets/lib/d3/d3.min.js',
                                    'assets/lib/c3/c3.min.js'                         
                                ]);
                            }
                        ]
                    },
                    controller: 'AppCtrl',
                    ncyBreadcrumb: {
                        label: 'Applications'
                    }
                })

                .state('auth.apps.create', {
                    page_title: 'New - Create',
                    url: '/create',
                    templateUrl: 'views/externals/connect_vm.html',
                    resolve: {
                        files: [
                            'uiLoad',
                            function (uiLoad) {
                                return uiLoad.load([
                                    // select2
                                    'assets/lib/select2/select2.css',
                                    'assets/lib/select2/select2.min.js',                                  
                                    // inputmask
                                    'assets/lib/jquery.inputmask/jquery.inputmask.bundle.min.js'

                                ]);
                            }
                        ]
                    },
                    controller: 'AddCtrl',
                    ncyBreadcrumb: {
                        label: 'Connect'
                    }
                })


                .state('auth.apps.validate', {
                    page_title: 'New - Validate',
                    url: '/validate',
                    templateUrl: 'views/externals/cluster_validation_vm.html',
                    resolve: {
                        VMsData: function(VMsList){
                            var vms_data = VMsList.getList();
                            return vms_data;
                        },
                        files: [
                            'uiLoad',
                            function (uiLoad) {
                                return uiLoad.load([
                                    // select2
                                    'assets/lib/select2/select2.css',
                                    'assets/lib/select2/select2.min.js'                              
                                ]);
                            }
                        ]
                    },
                    controller: 'ValidateCtrl',
                    ncyBreadcrumb: {
                        label: 'Validations'
                    }
                })
 }
]);

1 个答案:

答案 0 :(得分:1)

如果错误为auth.apps的原因是抽象的,则无法导航到抽象路径。

 .state('auth.apps', {
                    //abstract: true, <-- remove this
                    url: '/applications',
                    template: '<div ui-view autoscroll="false" class="mainView-animate"></div>',
                    ncyBreadcrumb: {
                        label: 'Applications'
                    }
                })