I have a ConfigService
written to get the configuration details before the angular app bootstraps.
The following code is written in the app.module.ts
this code works fine and I am able to load the configs before the app loads.
...
providers: [
{
provide: APP_INITIALIZER,
useFactory: configServiceFactory,
deps: [ConfigService],
multi: true
}
]
...
However, now I wanted to pass a payload to my config API which I have to read from the query parameters.
I tried the following but it throws
...
@Injectable()
export class ConfigService {
private _configData: any;
constructor(
private _http: Http,
private _activatedRoute: ActivatedRoute
) {
}
...
How do I read the query-parameters inside an APP_INITIALIZER service?
APP_INITIALIZER
is executed before the application is bootstrapped, Router is not initialized yet. Hooking into the Angular bootstrap process and How to manually bootstrap an Angular application might be of help to you – Rue