Let's say you have
var app = angular.module('Mod1',[])
and now you need to add something else to this module, but you cannot change this line, you only have access to the app variable.
So this will not work, right?
var mod2 = angular.module('mod2',[]).factory('$myService', function(){ return { do: function(){alert('doing'); } }) app.directive('foo',[$myService])
Of course, you can always:
injector = angular.injector(['mod2']) $myService = injector.get('$myService')
Although I wonder if there is a more elegant solution
angularjs
Agzam Jun 24 '13 at 20:31 on 2013-06-24 20:31
source share