对于angular,
$$phase 是 作为angular 内部状态表示位,用来标示当前是处于哪个阶段。
用有的阶段有
$digest$apply
在使用的是例如你想调用scope.$apply的时候,经常会遇到这样的错误
Error:$apply already in progress
为了预防这样的错误,
有人是这么写的
if (!scope.$$phase && !scope.$root.$$phase){ scope.$apply(); }
一个合理的做法
就是使用$timeout 代替使用,这种写法是目前最好的方法了。
$timeout(function(){ // anything you want can go here and will safely be run on the next digest.})