I am looking at an Angular hybrid app and its new for me.
Its app.module.ts has providers with upgraded AngularJS services under providers[..]:
It has UpgradeModule injected as:
constructor(
private upgrade: UpgradeModule
) { }
Then, there is the following:
ngDoBootstrap() {
const strictDi = typeof this.strictDi === 'boolean' ? this.strictDi : true;
this.upgrade.bootstrap(document.documentElement, ['app'], { strictDi });
}
I have an Angular service - AuthTokenService.ts
@Injectable
export class AuthTokenService ... {
..
}
I have a need where I want to inject this service AuthTokenService in app.module.ts constructor (to do some processing/check at that level before loading app) However, it looks like in hybrid Angular, I cannot simply inject it as:
constructor(
private upgrade: UpgradeModule,
private authTokenService: AuthTokenService // this is how I am trying to inject
) { }
When I load the app, it gives an error - Trying to get the AngularJS injector before it being set.
Any idea if and how I can inject an Angular service in the constructor of app.module.ts in a hybrid Angular app?