ng.getDirectives

From Get docs
< @angular/core‎ | globalAngular/docs/11/api/core/global/nggetdirectives


ng.getDirectives

global function

Retrieves directive instances associated with a given DOM element. Does not include component instances.

ng.getDirectives(element: Element): {}[]

Parameters
element Element DOM element for which to get the directives.
Returns

{}[]: Array of directives associated with the element.


Usage notes

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.


© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v11.angular.io/api/core/global/ngGetDirectives