名单宣布AngularJS模块的指令/控制器 [英] List declared directives/controllers in AngularJS module

查看:142
本文介绍了名单宣布AngularJS模块的指令/控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法可以列出所有已为一个给定的角模块定义的指令和控制器?例如,假设我主模块中定义三个控制器(即angular.module(主)。控制器('MainCtrl',函数(){...})。是否有办法让名单这三个控制器?

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 'main' module (i.e. angular.module('main').controller('MainCtrl',function() {...}). Is there are way to get the list of those three controllers?

推荐答案

嗯真的很难,而不是一件好事,我想,但是:

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

var app = angular.module('MyApp', []);

console.log(app._invokeQueue[0][2][1]);

_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.

如果你一个人乐的_invokeQueue你会看到很多的事情,你一定会喜欢的供应商的名称像下面,但他的类型太(指令,控制器,...);

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.

不要使用它在生产中!

这篇关于名单宣布AngularJS模块的指令/控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆