【发布时间】:2015-12-14 02:44:02
【问题描述】:
调用$digest或apply时出错
registerAjax = ->
successRegister = ->
$scope.showRegistrationPanel = false
$scope.showEndRegistrationPanel = true
$scope.$digest()
errorRegister = (response) ->
$scope.textErrorPanelRegistration = response.data.error
$scope.showErrorPanel = true
$scope.$apply()
data =
password: $scope.user.password
firstName: $scope.user.firstName
lastName: $scope.user.lastName
email: $scope.user.email
http.post REGISTER_URL, data
.then successRegister, errorRegister
当调用 $digest 或 $apply 时错误消失,但一切正常
Error: [$rootScope:inprog] http://errors.angularjs.org/1.4.7/$rootScope/inprog?p0=%24digest
at Error (native)
at http://localhost:8000/lib/angular/angular.min.js?M420gm3LwzcQLAcaXrk6IQ:6:416
【问题讨论】:
-
您是否在代码中使用
jQuery.ajax..那么显然您需要运行摘要循环..或者您可以尝试$timeout(function(){})运行安全摘要循环 -
所以没有必要运行摘要循环..如果您使用
$http方法制作ajax。
标签: javascript angularjs coffeescript