【发布时间】:2016-10-21 17:47:48
【问题描述】:
缩小我的 angularjs 代码后,我得到一个错误:
无法实例化模块应用程序,原因是: 错误:[$injector:unpr] 未知提供者:t
代码只有在运行 gulp 没有 --production 标志 时才有效。
//All dependencies used in below are minified in a single file
(function(){
angular
.module('app', [
'ngMessages',
'ngStorage',
'ngAnimate',
'toastr',
'ngSanitize'
]);
})();
服务代码
(function(){
'use strict';
angular
.module('app')
.factory('dataservice', dataservice);
dataservice.$inject = ['$http','$localStorage','toastr'];
function dataservice($http,$localStorage,toastr) {
//Code inside this function uses all 3 dependencies injected
}
})();
控制器代码
(function(){
'use strict';
angular
.module('app')
.controller('LoginController',LoginController);
LoginController.$inject = ['$localStorage','dataservice','toastr','$scope','$sanitize'];
function LoginController($localStorage,dataservice,toastr,$scope,$sanitize) {
/// All 5 dependencies injected here are used inside this function.
}
})();
【问题讨论】:
-
我现在很难提升东海岸 DDOS 的链接 bc,但请查看 ng-annotate - 它解决了缩小破坏 Angular 的问题。
标签: angularjs laravel gulp minify