Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
Say hello to Angular's future home!Check out Angular.devHome
/

ng.getOwningComponent

Retrieves the component instance whose view contains the DOM element.

See more...

      
      ng.getOwningComponent<T>(elementOrDir: {} | Element): T | null
    
Parameters
elementOrDir {} | Element

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

Returns

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

Description

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