MCPcopy
hub / github.com/angular/angular / injectRenderer2

Function injectRenderer2

packages/core/src/render/api.ts:257–264  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

255
256/** Injects a Renderer2 for the current component. */
257export function injectRenderer2(): Renderer2 {
258 // We need the Renderer to be based on the component that it's being injected into, however since
259 // DI happens before we've entered its view, `getLView` will return the parent view instead.
260 const lView = getLView();
261 const tNode = getCurrentTNode()!;
262 const nodeAtIndex = getComponentLViewByIndex(tNode.index, lView);
263 return (isLView(nodeAtIndex) ? nodeAtIndex : lView)[RENDERER] as Renderer2;
264}
265
266/**
267 * This enum is meant to be used by `ɵtype` properties of the different renderers implemented

Callers 1

api.tsFile · 0.85

Calls 4

getLViewFunction · 0.90
getCurrentTNodeFunction · 0.90
getComponentLViewByIndexFunction · 0.90
isLViewFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…