我想执行一个调用API的方法,因此一旦执行api,我想浏览URL。
当前,我已经尝试过以下代码:
this._router
.navigate(valuationRoute)
.then(data => {
if (!data) {
this.getContent();
}
})
private getContent = async () => {
try {
this.isLoaded = false;
localStorage.ReportDataStart = new Date();
this.isRefreshing = true;
this.spinnerService.show();
if (this._fundBusinessId && this._fundPeriod && this._templateTypeId) {
this.reportDataService.getContent(`val/api/${this._dealCode}/${this._fundPeriod}/${this._fundBusinessId}/${parseInt(this._templateTypeId)}`
);
}
} catch (error) {
this.isLoaded = false;
this.fireRefreshComments = true;
this.isRefreshing = false;
this.spinnerService.hide();
const errorMessage = this._customMessageService.formatError(error);
this._alertService.error(
this._messageService.displayReportError
);
}
}
我想调用this.getcontent
,并且在this.getcontent
内,一旦我要导航的api获得结果,就会调用api
。请帮助
答案 0 :(得分:0)
只需在API响应后添加路线导航代码,如下所示:
this.reportDataService.getContent(//yourparams).then(() => {
//put your navigation code here
this.router.navigate(//routepath)
})