Using ionic-v3: We have add button on home page,on click of which modal will be opened to add notes. After closing of that modal, no ionic life cycle hooks are getting called like ionViewDidEnter() or ionViewWillEnter(). We want to refresh home page with latest saved data after closing of saved notes modal.
Hey there.
Modals are just like popups and the page’s lifecycle methods aren’t called while dismissed.
Try this way:
Add a dismiss listener while presenting a modal:
async presentModal() {
const modal = await this.modalController.create({
component: ModalPagePage,
componentProps: { value: 123 }
});
modal.onDidDismiss().then(data=>{
console.log(data);
});
return await modal.present();
}
and in your modal ts file dismiss this way with data:
async closeModal(){
const onClosedData: string = "Wrapped Up!";
await this.modalController.dismiss(onClosedData);
}
now when you close the model, you’ll get the data like this:
{data: "Wrapped Up!", role: undefined}
Hope this helps you.