Here's safeApply as an Angular service you can attach to your module. Additionally, this version accounts for calls to $apply() that don't pass in a function. To use it, attach the following to your module:
.controller('MyCtrl', ['$scope,' 'safeApply', function($scope, safeApply) {
safeApply($scope); // no function passed in
safeApply($scope, function() { // passing a function in
});
}])
Here's safeApply as an Angular service you can attach to your module. Additionally, this version accounts for calls to $apply() that don't pass in a function. To use it, attach the following to your module:
and access it with dependency injection: