Skip to content

Instantly share code, notes, and snippets.

@dhoko
Last active November 13, 2019 06:33
Show Gist options
  • Save dhoko/601aae43bc23218f4aa422dd04394102 to your computer and use it in GitHub Desktop.
Save dhoko/601aae43bc23218f4aa422dd04394102 to your computer and use it in GitHub Desktop.
AngularJs - get list of all registered directives
const listDirectivesApp = () => {
const listDirectives = name => {
return angular
.module(name)
._invokeQueue
.filter(item => 'directive' === item[1])
.map(item => item[2][0]);
};
return angular
.modules
.map(listDirectives)
.reduce((acc, l) => acc.concat(l), []);
};
/*
Inside vendor.js
source: http://stackoverflow.com/questions/24889783/angularjs-get-list-of-all-registered-modules
*/
(function(orig) {
angular.modules = [];
angular.module = function() {
if (arguments.length > 1) {
angular.modules.push(arguments[0]);
}
return orig.apply(null, arguments);
}
})(angular.module);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment