我有一个看起来像这样的角度模块:
angular.module('simperiumAngular', []).
config(function(simperiumCred){
console.log(simperiumCred)
// var simperium = new Simperium('SIMPERIUM_APP_ID', { token : 'SIMPERIUM_ACCESS_TOKEN'});
})
如何从主角度模块传递常量simperiumCred,将第一个模块注入:
angular.module('todo', ['simperiumAngular']).
constant('simperiumCred','test').
答案 0 :(得分:0)
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链接,如何在配置文件中注入一些内容。
希望这是有帮助!!
答案 1 :(得分:0)
你的问题有点含糊不清。如果你想要的是访问另一个模块中定义的常量,那么这对我有用:
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);
}]);