ng.getContext

From Get docs
< @angular/core‎ | globalAngular/docs/10/api/core/global/nggetcontext


ng.getContext

global function

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

ng.getContext<T>(element: Element): T | null

Parameters
element Element Element for which to get the surrounding component instance.
Returns

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


© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v10.angular.io/api/core/global/ngGetContext