Skip to content

Instantly share code, notes, and snippets.

@cristobal
Last active August 29, 2015 14:03
Show Gist options
  • Save cristobal/d4a730f26fd5342e7324 to your computer and use it in GitHub Desktop.
Save cristobal/d4a730f26fd5342e7324 to your computer and use it in GitHub Desktop.
Simple Angular Emitter
/**
* 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