我有这样的模式(我知道使用纯jQuery真的很糟糕,但我想了解这个问题):
$http.get('/api/my').then(function(){
$('#item').find('input').focus(); //throws $digest already in progress
});
我无法想象find
方法在内部执行任何$scope.$apply();
当我评论或删除该行时,我没有问题。
原因是什么?
我找到了根本原因。
在另一个指令中:
inputElement.bind('focus', function () {
childScope.$field.onFocus = true;
childScope.$digest(); //oops...
});
无需对此代码进行注释:)