IonViewWillEnter不会被触发

时间:2020-07-29 13:56:44

标签: angular ionic-framework

所以我有3页(2个普通视图页和1个模式页)。 2个普通视图页面(页面A)之一打开模式页面,而模式页面调用另一个普通视图页面(B)。

B中有一个按钮可以更新数据库,然后返回到A。我需要使A与更新的数据库内联,以便在按B中的按钮后,它再次调用我在Web服务器中部署的API 。我知道离子视图页面的生命周期,我认为IonViewWillEnter / IonViewDidEnter可能会对我有所帮助。但是,使用两者之一时,从B弹出后都不会触发。

有帮助吗?

这是打字稿文件的片段。

正常模式页面(A),调用模式。方法loadData是对API服务的调用

while cv2.waitKey(1)

调用普通视图页面B的模式页面

ionViewWillEnter() {
this.loadData();
}

loadData(){
this.user = this.dataService.getParamData();
this.hcf_id = this.user.hcfId;
this.sub = this.roomService.getAllRooms(this.hcf_id).subscribe(e => {
this.rooms = e;
});
this.sub2 = this.roomService.getAllRoomByType(this.hcf_id, 1).subscribe(e => {
this.commonRooms = e;
});
this.sub3 = this.roomService.getAllRoomByType(this.hcf_id, 2).subscribe(e => {
this.functionalRooms = e;
});
}

async showDetails(response: Room){
const modal = await this.modalController.create({
component: ModalPage,
componentProps: {
room: response
}
});
modal.present();
}

普通视图页面B,该页面具有用于通过API更新数据库并弹出到A的按钮

closeModal(){
this.modalController.dismiss();
}

editLPGRP(room_id: Number){
this.dataService.pushTempData(this.lpgrpGen);
this.navCtrl.navigateForward(‘lpgrfgen’);
this.closeModal();
}

0 个答案:

没有答案
相关问题