global
function
Retrieves the component instance whose view contains the DOM element.
ng.getOwningComponent<T>(elementOrDir: {} | Element): T | null
elementOrDir | {} | Element | DOM element, component or directive instance for which to retrieve the root components. |
T | null
: Component instance whose view owns the DOM element or null if the element is not part of a component view.
For example, if <child-comp>
is used in the template of <app-comp>
(i.e. a ViewChild
of <app-comp>
), calling getOwningComponent
on <child-comp>
would return <app-comp>
.
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v10.angular.io/api/core/global/ngGetOwningComponent