简体   繁体   English

如何查找给定DOM元素的指令名称

[英]How to find directive name for given DOM element

Suppose you have some custom directive myDirectiveA and associated controller myControllerA with replace : true - it means that your custom directive name will not appear in DOM tree. 假设您有一些自定义指令myDirectiveA和关联的控制器myControllerA其中replace : true myControllerA这意味着您的自定义指令名称将不会出现在DOM树中。

How to find a directive name in this case? 在这种情况下如何找到指令名称?

(Something like angular.element($0)... ?) (有点像angular.element($0)... ?)

PS I know that replace:true is deprecated. PS我知道replace:true已被弃用。

I still haven't found a way to do this, so I assume it's not possible. 我仍然没有找到执行此操作的方法,因此我认为这是不可能的。 However, it's possible to get controller: 但是,有可能获得控制器:

angular.element($0).controller()

or a component's controller 或组件的控制器

angular.element($0).scope().$ctrl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM