我有一个angular-module,看起来像这样:
angular.module('simperiumAngular', []).
config(function(simperiumCred){
console.log(simperiumCred)
// var simperium = new Simperium('SIMPERIUM_APP_ID', { token : 'SIMPERIUM_ACCESS_TOKEN'});
})如何从注入第一个模块的主angular模块传递常量simperiumCred:
angular.module('todo', ['simperiumAngular']).
constant('simperiumCred','test').发布于 2014-05-06 23:34:43
angular.module('myModule', []).
config(function(injectables) { // provider-injector
// This is an example of config block.
// You can have as many of these as you want.
// You can only inject Providers (not instances)
// into config blocks.
});你可以看到这个reference的jsfiddle链接,如何在配置文件中注入一些东西。
希望这是帮助!
发布于 2014-05-06 23:44:16
你的问题有点模棱两可。如果您想要访问在另一个模块中定义的常量,那么这对我来说是有效的:
var other = angular.module('other',[]);
other.constant('message', {message: 'Hello World'});
var sample = angular.module('sample',['other']);
sample.config(['message', function(message){
alert(message.message);
}]);https://stackoverflow.com/questions/23498602
复制相似问题