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

Function injectArgs

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

Source from the content-addressed store, hash-verified

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