How to access/update $rootScope from outside Angular

后端 未结 3 1037
半阙折子戏
半阙折子戏 2020-11-29 04:13

My application initializes an object graph in $rootScope, like this ...

var myApp = angular.module(\'myApp\', []);

myApp.run(function ($rootScope) {
    $ro         


        
3条回答
  •  眼角桃花
    2020-11-29 04:43

    After you update the $rootScope call $rootScope.$apply() to update the bindings.

    Think of modifying the scopes as an atomic operation and $apply() commits those changes.

提交回复
热议问题