AngularJS - 丑化 angular.module
AngularJS - uglify angular.module
angular.module('myApplication').factory('myService', [function() {
return {
name: 'name'
};
}]);
当我试图在我的控制器中注入上述服务时。
myApplication.controller('myController', [ 'myService', function(myService) {}]);
丑化后出现以下错误:
错误:$注入器:unpr
未知供应商
未知提供者:myServiceProvider <- myService <- myController
您的代码应该使用相同的 angular 模块。
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
}
]);
angular.module('myApplication').factory('myService', [function() {
return {
name: 'name'
};
}]);
当我试图在我的控制器中注入上述服务时。
myApplication.controller('myController', [ 'myService', function(myService) {}]);
丑化后出现以下错误:
错误:$注入器:unpr 未知供应商 未知提供者:myServiceProvider <- myService <- myController
您的代码应该使用相同的 angular 模块。
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
}
]);