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

Function factory

packages/upgrade/src/common/src/downgrade_injectable.ts:76–89  ·  view source on GitHub ↗
($injector: IInjectorService)

Source from the content-addressed store, hash-verified

74 */
75export function downgradeInjectable(token: any, downgradedModule: string = ''): Function {
76 const factory = function ($injector: IInjectorService) {
77 const injectorKey = `${INJECTOR_KEY}${downgradedModule}`;
78 const injectableName = isFunction(token) ? getTypeName(token) : String(token);
79 const attemptedAction = `instantiating injectable '${injectableName}'`;
80
81 validateInjectionKey($injector, downgradedModule, injectorKey, attemptedAction);
82
83 try {
84 const injector: Injector = $injector.get(injectorKey);
85 return injector.get(token);
86 } catch (err) {
87 throw new Error(`Error while ${attemptedAction}: ${(err as Error).message || err}`);
88 }
89 };
90 (factory as any)['$inject'] = [$INJECTOR];
91
92 return factory;

Callers 1

Calls 4

isFunctionFunction · 0.90
getTypeNameFunction · 0.90
validateInjectionKeyFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…