MCPcopy
hub / github.com/angular/angular / assertInInjectionContext

Function assertInInjectionContext

packages/core/src/di/contextual.ts:77–88  ·  view source on GitHub ↗
(debugFn: Function)

Source from the content-addressed store, hash-verified

75 * @publicApi
76 */
77export function assertInInjectionContext(debugFn: Function): void {
78 // Taking a `Function` instead of a string name here prevents the unminified name of the function
79 // from being retained in the bundle regardless of minification.
80 if (!isInInjectionContext()) {
81 throw new RuntimeError(
82 RuntimeErrorCode.MISSING_INJECTION_CONTEXT,
83 ngDevMode &&
84 debugFn.name +
85 '() can only be used within an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`',
86 );
87 }
88}

Callers 15

toObservableFunction · 0.90
toSignalFunction · 0.90
rxResourceFunction · 0.90
pendingUntilEventFunction · 0.90
takeUntilDestroyedFunction · 0.90
outputFromObservableFunction · 0.90
di_spec.tsFile · 0.90
injectAsyncFunction · 0.90
onIdleFunction · 0.90
viewChildFnFunction · 0.90
viewChildRequiredFnFunction · 0.90
viewChildrenFunction · 0.90

Calls 1

isInInjectionContextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…