あなたが持っているとしましょう
var app = angular.module('Mod1',[])
そして今、そのモジュールに何か他のものを注入する必要がありますが、その行を変更することはできませんapp
。変数にしかアクセスできません。
これはうまくいきませんよね?
var mod2 = angular.module('mod2',[]).factory('$myService', function(){
return { do: function(){alert('doing'); }
})
app.directive('foo',[$myService]) // $myService here is undefined
もちろん、いつでもできます:
injector = angular.injector(['mod2'])
$myService = injector.get('$myService')
もっとエレガントな解決策があるかどうか疑問に思っていますが