3
我需要在角度初始化之前先做兩個HTTP調用。有什麼方法可以同步初始化角度2嗎?angular2 APP_INITIALIZER同步
請不要說我們的應用程序應該異步工作。 我正在使用「angular-cli」進行通用構建。首先,我需要獲取在json文件中設置的環境,並基於我需要加載配置的環境。所以我需要兩個HTTP調用。
{
provide: APP_INITIALIZER,
useFactory: (config: AppConfig) =>() => config.load(),
deps: [AppConfig], multi: true
}
內部負載()我有兩個http調用其中一個,但在兩個調用完成之前angular已初始化。
會https://github.com/angular/angular/issues/9047#issuecomment-255597990的工作?小心:APP_INITIALIZER是實驗性的:https://angular.io/docs/ts/latest/api/core/index/APP_INITIALIZER-let.html – Sebastian
@Rohit你能檢查我的答案嗎? – DDRamone