MCPcopy Index your code
hub / github.com/angular/angular / getRootContext

Function getRootContext

packages/core/src/render3/util/view_traversal_utils.ts:42–47  ·  view source on GitHub ↗
(viewOrComponent: LView<T> | {})

Source from the content-addressed store, hash-verified

40 * @param viewOrComponent the `LView` or component to get the root context for.
41 */
42export function getRootContext<T>(viewOrComponent: LView<T> | {}): T {
43 const rootView = getRootView(viewOrComponent);
44 ngDevMode &&
45 assertDefined(rootView[CONTEXT], 'Root view has no context. Perhaps it is disconnected?');
46 return rootView[CONTEXT] as T;
47}
48
49/**
50 * Gets the first `LContainer` in the LView or `null` if none exists.

Callers 1

getRootComponentsFunction · 0.90

Calls 2

assertDefinedFunction · 0.90
getRootViewFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…