[Ionic-v4] Modal Parameters

Did you try NavParams in your modal to get the params?

https://forum.ionicframework.com/t/ionic-4-get-data-in-modal-passed-with-componentprops/

As far I understand it works like following

To pass parameters to the modal, use componentProps

const modal: HTMLIonModalElement = this.modalController.create({
   component: MyModal,
   componentProps: {
      something: 'value',
      other: {couldAlsoBeAnObject: true}
   }
});

To get the values in your modal

  const something: string = this.navParams.get('something');

To close the modal and pass a value back

 this.modalController.dismiss(true);

or

 this.modalController.dismiss({couldAlsoBeAnObject: true});

Finally to get the dismissed value back

 modal.onDidDismiss((detail: OverlayEventDetail) => {
     console.log(detail ? detail.data : null); // The value or object is detail.data
 });
5 Likes