Hi,
When handling data returned from a modal using Ionic 4, if I write the following, this works:
async triggerModal() {
const r = await this.openModal(params);
console.log(this.returnedData);
}
async openModal(params)
{
const modal = await this.modalCtrl.create({
component: ModalComponent,
componentProps: params
});
await modal.present();
await modal.onDidDismiss().then((r) => {
this.returnedData = r.data;
});
}
But if I try it a different way, like this:
async triggerModal() {
const r = await this.openModal(params);
console.log(r);
}
async openModal(params)
{
const modal = await this.modalCtrl.create({
component: ModalComponent,
componentProps: params
});
await modal.present();
await modal.onDidDismiss().then((r) => {
return r.data
});
}
r is ‘undefined’.
I’m just trying to understand the reason for why this might be happening, and whether the second option should work or not.
Thanks