我有一個模塊(app.config),我想注入我的整個應用程序。如何注入模塊,並使其訪問角應用程序
模塊需要被注入到應用
舉例而言,所有其它模塊中訪問,我的應用程序是這樣的:
angular.module('myApp', [
'app.config',
'module#1',
'module#2',
'module#3',
'module#4'
])
.config...
////////// ///////////////////////
這裏的app.config
angular.module('app.config', []).
constant('NAME1', 'Name1').
constant('NAME2', 'Name2');
////////////////////
我想'app.config'注入的方式可以在所有模塊(模塊#1,模塊#2,....)內部訪問。
這裏是我的問題:
angular.module('module#1', []).
service('serviceOne', serviceOne);
function ServiceOne($http) {
var service = {
getMyProfile: function(){return $http.get('api/' + NAME1);}
};
return service;
}
問題 - >NAME1是不確定的。但我想我注入到整個應用程序?
我不想單獨將app.config注入到每個模塊。任何其他解決方案?