You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ./inject-decorator.tsimport*asangularfrom'angular';let_$injector: angular.auto.IInjectorService;exportfunctionregisterInjectDecoratorModule(){returnangular.module('td.injector',[]).run(functionregisterInjectDecorator($injector){_$injector=$injector;}).name;}/** * Usage property dependency injector decorator * * Usage: * * import {inject} from '@libs/inject-decorator'; * * class Foo { * * @inject() //property name the same as service name * private someService: SomeService * * @inject('barService') //explicit pass name of service to inject * private bar: BarService * * } */exportfunctioninject(name?: string){returnfunctioninjectDecorator(target: any,key: string){Object.defineProperty(target,key,{get: ()=>{constvalue=_$injector.get(name||key);Object.defineProperty(target,key,{
value,writable: false,enumerable: false,configurable: false,});returnvalue;},enumerable: false,configurable: true,});};}
Add injector decorator module to your root module in the top of queue before any other:
// app.ts - root moduleconstappModule=angular.module('app',[registerInjectDecoratorModule(),// your other modules ...])
Making this possible:
The text was updated successfully, but these errors were encountered: