I am new to Angualr 2 and RxJS (coming from Angular 1.x) and I am struggling with initializing the app properly.
Here is the scenario. My app needs some data from the server upon initializing. I was thinking of making an http call from the AppModule's constructor to retrieve this data, populate the service that will hold this data and then proceed with loading the app.
What is the best way to achieve this?
I tried using:
export class AppModule {
constructor(http: Http, common: CommonService) {
http.get('config').map(res => res.json()).do((cfg) => {
common.config = cfg;
});
}
}
But the code in do(...) never executes.
Thanks.