Pass data on modal close?


#1

Is there any way to pass some data to parent page from modal on close?


#2

Yes you can receive the data inside the onDidDismiss like this:

let myModal = this.modalCtrl.create('MyModalPage');
myModal.onDidDismiss(data => {
  // Data is your data from the modal
});
myModal.present();

Inside your Modal page you then have to pass the object inside the dismiss function like this:

this.viewCtrl.dismiss({specialData: 'whatever'});

That’s it!