Sometimes I need to use $scope.$apply in my code and sometimes it throws a \"digest already in progress\" error. So I started to find a way around this and foun
In any case when your digest in progress and you push another service to digest, it simply gives an error i.e. digest already in progress. so to cure this you have two option. you can check for anyother digest in progress like polling.
First one
if ($scope.$root.$$phase != '$apply' && $scope.$root.$$phase != '$digest') {
$scope.$apply();
}
if the above condition is true, then you can apply your $scope.$apply otherwies not and
second solution is use $timeout
$timeout(function() {
//...
})
it will not let the other digest to start untill $timeout complete it's execution.