Skip to content

Instantly share code, notes, and snippets.

@s9tpepper
Created July 9, 2014 14:03
Show Gist options
  • Save s9tpepper/fda4db10de6dca22b98d to your computer and use it in GitHub Desktop.
Save s9tpepper/fda4db10de6dca22b98d to your computer and use it in GitHub Desktop.
angular_module.config([ '$provide', function($provide) {
return $provide.decorator('$rootScope', [ '$delegate', function($delegate) {
$delegate.safeApply = function(fn) {
var phase = $delegate.$$phase;
if (phase === "$apply" || phase === "$digest") {
if (fn && typeof fn === 'function') {
fn();
}
} else {
$delegate.$apply(fn);
}
};
return $delegate;
}]);
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment