我正在从事离子角项目。我正在使用router.navigate
从一页导航到另一页。在下一页中,我将从API提取数组并显示为列表。这正常工作正常。但是,当我从Ionic Alertdialog导航时,此列表未显示。刷新页面后,将显示列表。在第2页中,this.deals
是实际列表。
// Page 2
ionViewWillEnter() {
this.fetchDealList();
}
fetchDealList() {
this.storage.get('userId').then((val1) => {
this.storage.get('Bearer').then((val2) => {
this.getDealList(val1, val2);
});
});
}
getDealList(myuserid, tokenString) {
let url = 'deals/bizuser';
let data = { userId: myuserid };
this.deals = [];
this.restService.parseModule(data, url, tokenString)
.then((response) => {
console.log("getDealList resp: " + JSON.stringify(response));
const mainResp = response as any[];
this.filterList(mainResp);
}, (error) => {
console.log(error.status);
});
}
filterList(mainResp){
this.deals = mainResp.filter((data) => {
return data.dealState == 3 && data.secondId == this.mySelectedBranchId;
});
}
// Page 1
async showBranches(pos) {
const alert = await this.alertController.create({
header: 'Branch Locations!',
inputs: this.branchArray,
buttons: [
{
text: "CANCEL",
handler: data => {
this.alertController.dismiss();
console.log("cancel clicked");
}
},
{
text: "OK",
handler: data => {
this.alertController.dismiss().then(() => {
console.log("branchId: " + data);
this.router.navigate(['draftdeals', { branchID: data }]);
});
}
}],
cssClass: 'alertRadioCustomCss'
});
await alert.present();
}