Reputation: 743
View code
<a ng-click="deleteOrdersUpdate()">Update</a>
<span class="red">{{noOfOrders}}</span>
Controller code
$scope.deleteOrdersUpdate=function () {
$scope.noOfOrders=$scope.selection.length;
scope.$apply();
};
I keep getting $rootScope:inprog Action Already In Progress error.
What is the correct way to do this?Can any one please point me in the right direction.
Upvotes: 0
Views: 74
Reputation: 6666
There's no reason to call $apply
here as you're already operating within the angular context.
$scope.deleteOrdersUpdate = function () {
$scope.noOfOrders = $scope.selection.length;
};
Upvotes: 3
Reputation: 1397
This is beacase $apply already in progress.you have to check the phase first .Here is good explanation and implement
angularjs-apply-digest-in-detail
Upvotes: 0
Reputation: 9780
You have to check if it is already in any digest cycle, if it is then it will be automatically done, you don't need to do this, if not then you can apply the scope
if(!$scope.$$phase) {
$scope.$apply();
}
Upvotes: 0