Created
September 17, 2013 15:12
-
-
Save janv/6595705 to your computer and use it in GitHub Desktop.
How to wrap your external callback for AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mymodule.factory('myWrappedService', function($rootScope){ | |
var originalService; // Must be set from somewhere of course | |
return { | |
myAsyncFunction: function(a,b,callback){ | |
return originalService.asyncFunction(a,b,function(){ | |
var args = arguments, self=this; | |
$rootScope.$apply(function(){ | |
callback.apply(self, arguments); | |
}) | |
}) | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment