Angular 2 get config from server before bootstrap
<p>I need to get configuration from server before the application bootstraps. I was able to do that using this in providers in my main ngModule:</p>

<pre><code>{
    provide: APP_INITIALIZER,
    useFactory: (links: Links) =&gt; () =&gt; links.init(),
    deps: [Links, Http],
    multi: true
}
</code></pre>

<p>Links service:</p>

<pre><code>init(): Promise&lt;any&gt; {
    var observable = this.http.get('someUrl').map(res =&gt; res.json());
    observable.subscribe(res =&gt; {
        this.config = res;
    });
    return observable.toPromise();
}
</code></pre>

<p>This code gets executed before the application bootstraps, but the response from server is not present until after my app asks for Links.config. How do I force the app to not bootstrap until after the Promise gets resolved? I tried promise.resolve(), but it didn't help.</p>

<p>The way I used providers I thought I forced the app to use the same instance of Links and also I thought the data would be already present there. What am I doing wrong please? </p>