getOwningComponent
function
Retrieves the component instance whose view contains the DOM element.
API
Description
function getOwningComponent<T>( elementOrDir: {} | Element): T | null;
getOwningComponent
T | null
Retrieves the component instance whose view contains the DOM element.
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>
.
@paramelementOrDir
{} | Element
DOM element, component or directive instance for which to retrieve the root components.
@returns
T | null
Jump to details