List declared directives/controllers in AngularJS module

后端 未结 1 362
挽巷
挽巷 2020-12-14 08:42

Is there a way to list all of the directives and controllers that have been defined for a given angular module? For example, imagine I define three controllers in the \'mai

相关标签:
1条回答
  • 2020-12-14 09:18

    Hmm really hard and not a good thing i think but :

    var app = angular.module('MyApp', []);
    
    console.log(app._invokeQueue[0][2][1]);
    

    _invokeQueue is an array if you do that for each entry getting the [0][2][1] you'll see the name of each provider in your module.

    If you lok the _invokeQueue alone you'll see a lot of things that you'll like the name of the provider like below but his type too (directive, controller, ...);

    But you feel that this is a tricky thing not a good thing a really bad practice but anyway really fun.

    Don't use it in production !

    0 讨论(0)
提交回复
热议问题