是否可以判断现在处于一个digest cycle中?直接用$rootScope.$$phase判断吗?我想判断如果没有处理轮询中就手动调用scope.$digest(),这个可以用$evalAsync解决吗?
1 回答

杨__羊羊
TA贡献1943条经验 获得超7个赞
目前AngularJS未提供公开的API判断,不过我翻了一下源码发现:ngModelDirective 指令写法中有这么一段
if ($rootScope.$$phase) { scope.$evalAsync(modelCtrl.$setTouched); } else { scope.$apply(modelCtrl.$setTouched); }
通过$rootScope.$$phase
判断当前如果在digest循环中,调用scope.$evalAsync
,不在则调用 scope.$apply
添加回答
举报
0/150
提交
取消