This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$digest error when using ng-blur in an ng-if #4979
Closed
Description
I have two input fields both set to autofocus. Each input field is inside an ng-if condition that is mutually exclusive. The condition starts out false showing the one input field, and when an http call finishes, the condition is set to true, removing one DOM and showing the other. When the initial one gets hid, it triggers the ng-blur event, but I get this exception:
Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.2.0/$rootScope/inprog?p0=%24digest
at https://192.168.20.248:8011/ui/dependencies/angular/angular.js:78:12
at beginPhase (https://192.168.20.248:8011/ui/dependencies/angular/angular.js:11830:15)
at Scope.$apply (https://192.168.20.248:8011/ui/dependencies/angular/angular.js:11627:11)
at HTMLInputElement.<anonymous> (https://192.168.20.248:8011/ui/dependencies/angular/angular.js:17425:21)
at HTMLInputElement.jQuery.event.dispatch (https://192.168.20.248:8011/ui/dependencies/jquery/jquery.js:5095:9)
at HTMLInputElement.elemData.handle (https://192.168.20.248:8011/ui/dependencies/jquery/jquery.js:4766:28)
at https://192.168.20.248:8011/ui/dependencies/angular-animate/angular-animate.js:875:54
at forEach (https://192.168.20.248:8011/ui/dependencies/angular/angular.js:303:18)
at getElementAnimationDetails (https://192.168.20.248:8011/ui/dependencies/angular-animate/angular-animate.js:871:11)
at animateSetup (https://192.168.20.248:8011/ui/dependencies/angular-animate/angular-animate.js:957:23)
HTML
<div ng-controller="MyCtrl">
<div ng-if="result">
<form>
<input type="text" required autofocus class="form-control" ng-blur="focusStolen()" />
Result is back
</form>
</div>
<div ng-if="!result">
<form>
<input type="text" required autofocus class="form-control" />
Awaiting result
</form
</div>
</div>
Script
var app = angular.module('myApp', []);
app.controller('MyCtrl', ['$scope', '$http', function($scope, $http) {
function refresh() {
$http.get('index.html').then(function() {
$scope.result = true;
});
}
refresh();
}]);