Passing from old code to Angular via rootScope

I am trying to pass a message from an old javascript function to the w50> controller through the Angular service. Broadcasting works fine when called inside Angular, but not outside. See http://jsfiddle.net/yh3Ds/24/

+4
source share
1 answer

It seems that angular.injector() creates a new module instance and it does not depend on the module instance associated with html via the ng-app attribute.

Thus, the solution is to use a manual bootstrap and get an injector there. Use this injector, you can access the service instance and $rootScope , which actually controls the view.

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

+7
source

Source: https://habr.com/ru/post/1435413/


All Articles