angular.module('myApplication').factory('myService', [function() {
return {
name: 'name'
};
}]);
当我尝试在我的控制器中注入以上服务时。
myApplication.controller('myController', [ 'myService', function(myService) {}]);
在uglifying它之后,它给出了我的错误:
错误:$ injector:unpr 未知的提供商 未知提供者:myServiceProvider< - myService< - myController
答案 0 :(得分:1)
您的代码应使用相同的角度模块。
angular.module('myApplication', []); //inject dependency in [] if anything there
angular.module('myApplication').factory('myService', [function() {
return {
name: 'name'
};
}]);
angular.module('myApplication').controller('myController', ['myService',
function(myService) {
//controller code here
}
]);