forked from PatrickJS/angular-off
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathangular-off.js
32 lines (26 loc) · 978 Bytes
/
angular-off.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(function (module, undefined) {
'use strict';
/* Config */
module.config(['$provide', function ($provide) {
var self = this;
function ngOff(eventName, fn) {
if (self.$$listeners) {
if (arguments.length > 1) {
var namedListeners = self.$$listeners[eventName];
if (namedListeners) {
namedListeners.splice(namedListeners.indexOf(fn), 1);
}
} else {
self.$$listeners[eventName] = null;
} // end args > 1
} // end if $$listeners
}
$provide.decorator('$rootScope', ['$delegate', function($delegate) {
Object.defineProperty($delegate.constructor.prototype, '$off', {
value: ngOff,
enumerable: false
});
return $delegate;
}]);
}]);
}(angular.module('angular-off', []), angular));