复制: 防止在调用$ scope。$ apply()时发生错误$digest。
您收到的错误表明Angular的脏检查已经在进行中。
最新的最佳实践表明,
$timeout如果要在下一个 摘要 迭代中执行任何代码,则应使用:
$timeout(function() { // the pre you want to run in the next digest});上一页反应: (不要使用此方法)
使用安全的申请,例如:
$rootScope.$$phase || $rootScope.$apply();
你为什么不反转条件?
$scope.$on('$locationChangeStart', function (event, next, current) { if (confirm("Are you sure you want to leave this page?")) { event.preventDefault(); }});


