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

Function injectArgs

packages/core/src/di/injector_compatibility.ts:327–362  ·  view source on GitHub ↗
(types: (ProviderToken<any> | any[])[])

Source from the content-addressed store, hash-verified

325}
326
327export function injectArgs(types: (ProviderToken<any> | any[])[]): any[] {
328 const args: any[] = [];
329 for (let i = 0; i < types.length; i++) {
330 const arg = resolveForwardRef(types[i]);
331 if (Array.isArray(arg)) {
332 if (arg.length === 0) {
333 throw new RuntimeError(
334 RuntimeErrorCode.INVALID_DIFFER_INPUT,
335 ngDevMode && 'Arguments array must have arguments.',
336 );
337 }
338 let type: Type<any> | undefined = undefined;
339 let flags: InternalInjectFlags = InternalInjectFlags.Default;
340
341 for (let j = 0; j < arg.length; j++) {
342 const meta = arg[j];
343 const flag = getInjectFlag(meta);
344 if (typeof flag === 'number') {
345 // Special case when we handle @Inject decorator.
346 if (flag === DecoratorFlags.Inject) {
347 type = meta.token;
348 } else {
349 flags |= flag;
350 }
351 } else {
352 type = meta;
353 }
354 }
355
356 args.push(ɵɵinject(type!, flags));
357 } else {
358 args.push(ɵɵinject(arg));
359 }
360 }
361 return args;
362}
363
364/**
365 * Attaches a given InjectFlag to a given decorator using monkey-patching.

Callers 2

processProviderMethod · 0.90
providerToFactoryFunction · 0.90

Calls 5

resolveForwardRefFunction · 0.90
getInjectFlagFunction · 0.85
ɵɵinjectFunction · 0.85
isArrayMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…