ng.getDirectives
Retrieves directive instances associated with a given DOM element. Does not include component instances.
ng.getDirectives(element: Element): {}[]
参数
element | Element | DOM element for which to get the directives. |
返回值
{}[]
: Array of directives associated with the element.
使用说明
Given the following DOM structure:
<my-app>
<button my-button></button>
<my-comp></my-comp>
</my-app>
Calling getDirectives
on <button>
will return an array with an instance of the MyButton
directive that is associated with the DOM element.
Calling getDirectives
on <my-comp>
will return an empty array.