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

Class RetrievingInjector

packages/core/src/di/injector_compatibility.ts:49–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 * This is used to allow the `inject` function to be used with the new primitives-based DI system.
48 */
49export class RetrievingInjector implements PrimitivesInjector {
50 constructor(readonly injector: Injector) {}
51 retrieve<T>(token: PrimitivesInjectionToken<T>, options: unknown): T | NotFound {
52 const flags: InternalInjectFlags =
53 convertToBitFlags(options as InjectOptions | undefined) || InternalInjectFlags.Default;
54 try {
55 return (this.injector as BackwardsCompatibleInjector).get(
56 token as unknown as InjectionToken<T>,
57 // When a dependency is requested with an optional flag, DI returns null as the default value.
58 (flags & InternalInjectFlags.Optional ? null : THROW_IF_NOT_FOUND) as T,
59 flags,
60 ) as T;
61 } catch (e: any) {
62 if (isNotFound(e)) {
63 return e;
64 }
65 throw e;
66 }
67 }
68}
69
70export const NG_TEMP_TOKEN_PATH = 'ngTempTokenPath';
71const NG_TOKEN_PATH = 'ngTokenPath';

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…