Running $apply on $rootScope vs any other scope

前端 未结 4 2167
故里飘歌
故里飘歌 2021-01-07 16:11

The $apply function can run on any scope, including $rootScope.

Are there cases when it makes a difference if I run it on my local scope or

4条回答
  •  渐次进展
    2021-01-07 16:39

    Running $digest/$apply on any given scope will visit all other scopes using depth-first traversal:

    https://github.com/angular/angular.js/blob/3967f5f7d6c8aa7b41a5352b12f457e2fbaa251a/src/ng/rootScope.js#L550-L558

    That means that the only difference is that the $digest will start at whatever $scope it was called on

提交回复
热议问题