UNPKG

@yaagoub/decorators

Version:

Angular decorators

29 lines (28 loc) 810 B
/** * @description * The `YgbInjector` class provides a static way to set and use an Angular `Injector`. * This allows for dependency injection to be managed and accessed globally within the application. * * @example * To set the injector, use the following code in your `app.config.ts`: * ```typescript * { * provide: APP_INITIALIZER, * useFactory: (injector: Injector) => () => YgbInjector.setInjector(injector), * deps: [Injector], * multi: true, * } * ``` * * @example * To inject a dependency: * ```typescript * const myService = YgbInjector.inject<MyService>(MyService); * ``` */ import { Injector } from "@angular/core"; export declare class YgbInjector { private static injector; static setInjector(injector: Injector): void; static inject<T>(token: any): T; }