Provide this in your root module
{provide: APP_INITIALIZER, useValue: () => promise, multi: true}]}
where () => promise
is some call that returns a Promise that resolves to the desired value.
See also How to pass parameters rendered from backend to angular2 bootstrap method
You can pass a service as dependency where you can store the result.
update
export function loadConfig(config: ConfigService) => () => config.load()
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule,
routes,
FormsModule,
HttpModule],
providers: [AuthService,
Title,
appRoutingProviders,
ConfigService,
{ provide: APP_INITIALIZER,
useFactory: loadConfig,
deps: [ConfigService],
multi: true }
],
bootstrap: [AppComponent]
})
export class AppModule { }
update 2
Plunker example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…