Skip to content

Instantly share code, notes, and snippets.

@janv
Created September 17, 2013 15:21
Show Gist options
  • Save janv/6595829 to your computer and use it in GitHub Desktop.
Save janv/6595829 to your computer and use it in GitHub Desktop.
use wrapply to wrap your callbacks in $rootScope.$apply()
angular.module('wrapply', []).factory('wrapply', ['$rootScope', function($rootScope){
return function wrapply(originalCallback){
return function wrappedCallback(){
var args=arguments, self=this, retval;
$rootScope.$apply(function(){
retval = originalCallback.apply(self, args);
});
return retval;
}
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment