Skip to content

Instantly share code, notes, and snippets.

View Benoit-Besnier's full-sized avatar

Benoit Besnier Benoit-Besnier

View GitHub Profile
@turtlemonvh
turtlemonvh / main.js
Last active January 3, 2021 16:37
Angular Messaging
var MyApp = angular.module('MyApp');
MyApp.factory('msgBus', ['$rootScope', function($rootScope) {
var msgBus = {};
msgBus.emitMsg = function(msg, data) {
data = data || {};
$rootScope.$emit(msg, data);
};
msgBus.onMsg = function(msg, func, scope) {
var unbind = $rootScope.$on(msg, func);
if (scope) {