angular.js:11706 Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.3.20/$rootScope/inprog?p0=%24digest
at angular.js:63
at beginPhase (angular.js:14924)
at Scope.$apply (angular.js:14668)
at HTMLDocument.<anonymous> (multiselect.js:162)
at HTMLDocument.dispatch (jquery.js:5206)
at HTMLDocument.elemData.handle (jquery.js:5014)
at repayQueryListCtr.js:135
at angular.js:9433
at processQueue (angular.js:13318)
at angular.js:13334
我这里报错是因为multiselect.js里有一段代码:
$document.on('click', function (e) {
var target = e.target.parentElement;
var parentFound = false;
while (angular.isDefined(target) && target !== null && !parentFound) {
if (_.contains(target.className.split(' '), 'multiselect-parent') && !parentFound) {
if(target === $dropdownTrigger) {
parentFound = true;
}
}
target = target.parentElement;
}
if (!parentFound) {
$scope.$apply(function () {
$scope.open = false;
});
}
});
为所有的文档节点都加了click事件,会调用$apply方法。
需要在自己的事件中调用event.stopPropagation(); event.stopPropagation() 方法阻止事件冒泡到父元素,阻止任何父事件处理程序被执行。
a.addEventListener("click", function() {
event.stopPropagation();
}, false);