Reputation: 88
Take a look at my code
$scope.update = function () {
//remove empty row in list before update
if ($scope.PatternData.length > 1) {
removeEmptyRow($scope.PatternData);
}
if (!$scope.$$phase) {
$scope.$apply();
}
$scope.$apply();
//update data
orderPatternService.updatePattern(function () {
//reload datatable
$scope.tableParams.reload();
//display notification
$timeout(function () {
notifyService.popEdit();
});
},$scope.PatternData);
};
I want to remove empty row in list before update
and update data
actions to occur at the same time, so I put
if (!$scope.$$phase) {
$scope.$apply();
}
$scope.$apply();
in between those two actions.
I have achieved my ideas without any influence, however, the Error: [$rootScope:inprog] $apply already in progress
error has occurred in the console
Please let me know the cause of this error
Upvotes: 0
Views: 1518
Reputation: 1641
You have probably error in the code:
if (!$scope.$$phase) { // If you are controlling the digest phase like this,
$scope.$apply();
}
$scope.$apply(); // then this line is not necessary!
Upvotes: 1