MCPcopy Create free account
hub / github.com/angular/angular / retrieve

Method retrieve

packages/core/src/di/r3_injector.ts:249–265  ·  view source on GitHub ↗
(token: PrimitivesInjectionToken<T>, options?: unknown)

Source from the content-addressed store, hash-verified

247 }
248
249 retrieve<T>(token: PrimitivesInjectionToken<T>, options?: unknown): T | NotFound {
250 const flags: InternalInjectFlags =
251 convertToBitFlags(options as InjectOptions | undefined) || InternalInjectFlags.Default;
252 try {
253 return (this as BackwardsCompatibleInjector).get(
254 token as unknown as InjectionToken<T>,
255 // When a dependency is requested with an optional flag, DI returns null as the default value.
256 THROW_IF_NOT_FOUND as T,
257 flags,
258 );
259 } catch (e: any) {
260 if (isNotFound(e)) {
261 return e;
262 }
263 throw e;
264 }
265 }
266
267 /**
268 * Destroy the injector and release references to every instance or provider associated with it.

Callers

nothing calls this directly

Calls 3

convertToBitFlagsFunction · 0.90
isNotFoundFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected