I have a @Injectable service defined in bootstrap. I want to get the instance of the service without using constructor injection. I tried using Reflective
In the updated Angular where ngModules are used, you can create a variable available anywhere in the code:
export let AppInjector: Injector;
export class AppModule {
constructor(private injector: Injector) {
AppInjector = this.injector;
}
}
Now, you can use the AppInjector to find any service in anywhere of your code.
import {AppInjector} from '../app.module';
const myService = AppInjector.get(MyService);