I am using modal and want to call a function after dismiss the modal.
i have tried onDidDismiss()
method but it shows an error
async openModal() {
const modal = await this.modal.create({ component: UploadPage });
modal.onDidDismiss(() => {
this.getData();
});
return await modal.present();
}
getData() {
......
}
in this way i got an error "Expected 0 arguments, but got 1."
onDidDismiss()
returns Promise<OverlayEventDetail<any>>
.
Try as follows.
const modal = await modalController.create({ component: UploadPage });
const { data } = await modal.onDidDismiss();
if (data) {
this.getData();
}
As other answers stated, now onDidDismiss() also returns a promise. So you can follow how documentation advises you to capture data or do something like this, its just another syntax basically:
async openModal() {
const modal = await this.modal.create({ component: UploadPage });
modal.onDidDismiss().then((data) => {
console.log(data)
});
return await modal.present();
}
actual data will be inside data.data in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With