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

Method constructor

packages/core/src/di/r3_injector.ts:219–247  ·  view source on GitHub ↗
(
    providers: Array<Provider | EnvironmentProviders>,
    readonly parent: Injector,
    readonly source: string | null,
    readonly scopes: Set<InjectorScope>,
  )

Source from the content-addressed store, hash-verified

217 private injectorDefTypes: Set<Type<unknown>>;
218
219 constructor(
220 providers: Array<Provider | EnvironmentProviders>,
221 readonly parent: Injector,
222 readonly source: string | null,
223 readonly scopes: Set<InjectorScope>,
224 ) {
225 super();
226 // Start off by creating Records for every provider.
227 forEachSingleProvider(providers as Array<Provider | InternalEnvironmentProviders>, (provider) =>
228 this.processProvider(provider),
229 );
230
231 // Make sure the INJECTOR token provides this injector.
232 this.records.set(INJECTOR, makeRecord(undefined, this));
233
234 // And `EnvironmentInjector` if the current injector is supposed to be env-scoped.
235 if (scopes.has('environment')) {
236 this.records.set(EnvironmentInjector, makeRecord(undefined, this));
237 }
238
239 // Detect whether this injector has the APP_ROOT_SCOPE token and thus should provide
240 // any injectable scoped to APP_ROOT_SCOPE.
241 const record = this.records.get(INJECTOR_SCOPE) as Record<InjectorScope | null>;
242 if (record != null && typeof record.value === 'string') {
243 this.scopes.add(record.value as InjectorScope);
244 }
245
246 this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, {self: true}));
247 }
248
249 retrieve<T>(token: PrimitivesInjectionToken<T>, options?: unknown): T | NotFound {
250 const flags: InternalInjectFlags =

Callers

nothing calls this directly

Calls 8

processProviderMethod · 0.95
getMethod · 0.95
forEachSingleProviderFunction · 0.85
makeRecordFunction · 0.85
setMethod · 0.65
hasMethod · 0.65
getMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected