我有下面的 AngularJS Controller 代码
(function() {
'use strict';
angular
.module('app')
.controller('TemplateCtrl', TemplateCtrl);
function TemplateCtrl($http, $auth, $rootScope,$scope){
}
})();
从 http://jscompress.com/ 压缩后我得到以下输出。
!function(){"use strict";function t(t,l,n,e){}angular.module("app").controller("TemplateCtrl",t)}();
压缩前没有错误,但压缩后出现以下错误
Error: [$injector:unpr] Unknown provider: tProvider <- t <- TemplateCtrl
我没有找到任何线索来解决这个问题?
感谢您的帮助和时间。
最佳答案
对于 Angular 压缩,你需要做一些额外的事情。你需要让它知道如何压缩依赖关系。所以你需要这个:
(function() {
'use strict';
angular
.module('app')
.controller('TemplateCtrl', ["$http", "$auth", "$rootscope", "$scope", TemplateCtrl]);
function TemplateCtrl($http, $auth, $rootScope,$scope){
}
})();
关于javascript - 错误: Unknown provider After JavaScript Compression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35409578/