Question

I am trying to broadcast a message from legacy javascript function into Angular controller(s) via a Angular service. Broadcasting works fine when called within Angular, but not outside. See http://jsfiddle.net/yh3Ds/24/

Était-ce utile?

La solution

It seems that angular.injector() is creating new module instance and it is independent from the module instance bound with the html via ng-app attribute.

So solution is to use manual bootstrap and obtain the injector there. Use this injector you can access the service instance and $rootScope which is actually controlling the view.

Here is the updated fiddle; http://jsfiddle.net/d8vX3/1/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top