Created
April 14, 2016 17:00
-
-
Save manrueda/4c314d36aa561d90c585eb0c15aea661 to your computer and use it in GitHub Desktop.
Intercept angular.module function before his creation
This file contains 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
window.angular = {}; | |
window.angular.modules = {}; | |
var originalModuleFunc; | |
var customFunction = function(){ | |
if (arguments.length > 1) { | |
angular.modules[arguments[0]] = originalModuleFunc.apply(null, arguments); | |
return angular.modules[arguments[0]]; | |
}else{ | |
return originalModuleFunc.apply(null, arguments); | |
} | |
} | |
Object.defineProperty(window.angular, 'module', { | |
get: function() { | |
return originalModuleFunc ? customFunction : undefined; | |
}, | |
set: function(value) { | |
originalModuleFunc = value; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment