Life cycle event on enter?

Is there any life cycle event that will got fired every single time page is being browsed? I know there is ionViewDidEnter but it doesn’t got triggered when Modal is closed for example.

You should use ionViewDidEnter() to detect whether a page was entered. In case of a Modal, listen to the modal.onDismiss() instead. An example copied from the docs over here:

 presentProfileModal() {
   let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });
   profileModal.onDidDismiss(data => {
     console.log(data);
   });
   profileModal.present();
 }

}

You can then execute your code onDidDismiss.

Thanks! Thats a good idea

To clarify further: the reason why ionViewDidEnter isn’t called when opening a modal, is that the page actually was never left. The modal actually pops up on top of the current page and isn’t added to the stack as a new page. Ergo, leaving the modal doesn’t trigger ionViewDidEnter on the page, since it was never left in the first place.

I’m curious what the purpose of this is.

on my modal page i am inserting new data into chart i have to refresh this chart somehow when modal is closed

That seems like a really typical situation that does not require lifecycle events. Ordinary modifications to controller properties should be automatically reflected.

1 Like

I’m using a modal to edit data for display which is stored in a JSON object.
Therefore to permit cancellation I make a deep copy of the object (it is actually an object with a list of objects so is passed by reference). I alter the copy and only copy it back into the original larger object (a JSON list) if the changes are saved.
I need to make a fresh copy each time I enter the Modal but as it doesn’t trigger a lifecycle event, I don’t know where I can do this.
Any help would be appreciated.

Thanks

Shane