Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Intercept angular.module function before his creation
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
You can’t perform that action at this time.