• 개요
@angular/core/globals

getOwningComponent

함수
안정화

Retrieves the component instance whose view contains the DOM element.

API

function getOwningComponent<T>(elementOrDir: {} | Element): T | null;
@paramelementOrDir{} | Element

DOM element, component or directive instance for which to retrieve the root components.

@returnsT | null

Component instance whose view owns the DOM element or null if the element is not part of a component view.

설명

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>.

상세 내용으로 이동