Skip to content

Instantly share code, notes, and snippets.

@vitalyrotari
Created September 3, 2013 16:31
Show Gist options
  • Save vitalyrotari/6426228 to your computer and use it in GitHub Desktop.
Save vitalyrotari/6426228 to your computer and use it in GitHub Desktop.
AngularJS safe apply helper
/**
* @param {Scope} scope
* @param {Function} callback
*/
angular.safeApply = function (scope, callback) {
scope[(scope.$$phase || scope.$root.$$phase) ? '$eval' : '$apply'](callback || function() {});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment