[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/core/globals/getContext [Back]  [Original]

getContext Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/core/globals

getContext

function
stable

If inside an embedded view (e.g. *ngIf or *ngFor), retrieves the context of the embedded view that the element is part of. Otherwise retrieves the instance of the component whose view owns the element (in this case, the result is the same as calling getOwningComponent).

On this page

    arrow_upward_alt Back to the top

    API

    function getContext<T extends {}>(element: Element): T | null;
    @paramelementElement

    Element for which to get the surrounding component instance.

    @returnsT | null

    Instance of the component that is around the element or null if the element isn't inside any component.

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page