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

Class ChainedInjector

packages/core/src/render3/chained_injector.ts:18–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 * injector. Used primarily when creating components or embedded views dynamically.
17 */
18export class ChainedInjector implements Injector {
19 constructor(
20 public injector: Injector,
21 public parentInjector: Injector,
22 ) {}
23
24 get<T>(token: ProviderToken<T>, notFoundValue?: T, options?: InjectOptions): T {
25 const value = this.injector.get<T | typeof NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR>(
26 token,
27 NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR,
28 options,
29 );
30
31 if (
32 value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
33 notFoundValue === (NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR as unknown as T)
34 ) {
35 // Return the value from the root element injector when
36 // - it provides it
37 // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
38 // - the module injector should not be checked
39 // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
40 return value as T;
41 }
42
43 return this.parentInjector.get(token, notFoundValue, options);
44 }
45}

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…