Last active
August 29, 2015 14:03
-
-
Save cristobal/d4a730f26fd5342e7324 to your computer and use it in GitHub Desktop.
Simple Angular Emitter
This file contains hidden or 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
/** | |
* Simple emitter with broadcast, emit, on event functions. | |
*/ | |
app.factory('emitter', function ($rootScope) { | |
var service = {}; | |
angular.forEach(['broadcast' 'emit', 'on'], function (key) { | |
service[key] = angular.bind($rootScope['$' + $key], $rootScope); | |
}); | |
return service; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment