bit*_*wit 20 javascript angularjs
我有以下代码:
appModule = angular.module('appModule', []);
appModule.factory('sharedApplication', function($rootScope, $http) {
var sharedApp;
sharedApp = {};
sharedApp.currentView = "home-section";
sharedApp.pastEvents = null;
$http.get('api/highlights').success(function(response) {
return sharedApp.pastEvents = response.data;
});
return sharedApp;
});
Run Code Online (Sandbox Code Playgroud)
这段代码完美无缺,正如我所料,直到我尝试缩小我的javascript,然后我得到
Error: Unknown provider: eProvider <- e
Run Code Online (Sandbox Code Playgroud)
这是因为我的工厂函数中的$ http参数已重命名为'e'以进行缩小.那么如何手动通知appModule按名称注入什么以避免缩小我的代码?
提前致谢.
kfi*_*fis 44
尝试
appModule.factory('sharedApplication', ['$rootScope','$http',function($rootScope, $http) {
}]);
Run Code Online (Sandbox Code Playgroud)
问候
| 归档时间: |
|
| 查看次数: |
18592 次 |
| 最近记录: |