Wildcards for listening scope broadcasts with $on on AngularJs
angularjs
Solution
In the angular js source code, `$on` is defined as follows:
$on: function(name, listener) {
var namedListeners = this.$$listeners[name];
if (!namedListeners) {
this.$$listeners[name] = namedListeners = [];
}
namedListeners.push(listener);
return function() {
namedListeners[indexOf(namedListeners, listener)] = null;
};
},
since `this.$$listeners` is an associative array, and associative arrays in javascript do not take regexs as keys, this suggests that the short answer is "no you can not".
Problem
Is there a way to capture scope broadcasts using wildcards on AngularJS? Example: ` $rootScope.$on('*created', function () { // do stuff }); `