如何解决angularjs中的“未知提供者”问题

时间:2016-09-07 07:52:37

标签: angularjs angularjs-scope angular-ui-router

当我使用ui-router并解决它时会出现“未知提供程序”错误。下面我提到了浏览器控制台上打印的错误。

Error: [$injector:unpr] Unknown provider: appFacilityListProvider <- appFacilityList <- facilityController 
http://errors.angularjs.org/1.5.0/$injector/unpr?p0=appFacilityListProvider%20%3C-%20appFacilityList%20%3C-NaNacilityController 
minErr/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:68:12 
createInjector/providerCache.$injector<@https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js:4397:19

设施控制器

app.controller('facilityController', 
    ['$scope','$rootScope','$location','$filter', 'facilityService', 'appFacilityList','facilityDTO',
    function ($scope,$rootScope,$location,$filter, facilityService,appFacilityList,facilityDTO) {

    }
);

app.js

.state('facility.newFacility', {
    url: '/newFacility',
    views: {
        header: {
            templateUrl: "/views/common/layout/navbar.html"
        },
        facilityHome: {
            templateUrl: '/views/facility/newFacility.html',
            controller: 'facilityController',
            resolve: {
                facilityDTO  : function() {
                    return null;
                },
                appFacilityList  : function( ) {
                    return null;
                }
            }
        },
        footer: {
            templateUrl: "/views/common/layout/footer.html"
        }
    }
})

1 个答案:

答案 0 :(得分:1)

因为你说如果从div中删除ng-controller它可以工作......那么为什么不尝试从div中删除ng-controller并在facilityHome视图中使用controllerAs: 'ctrl'controller: 'facilityController',controllerAs: 'ctrl'