Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230975

Page calls modal1 that calls modal2: how to get data from modal2 to page?

$
0
0

Hello, I have a page that calls a modal which then calls another modal. The first modal is dismissed when the second modal appears. Now, depending on what a user does in the second modal, there might be data that needs to be returned to the page. Usually I would use the “onDidDismiss”-Function but with this I would return data from the second modal to the first modal (that is already dismissed when the data from the 2. modal arrives)
How would I get data from the second modal to the page? Here some code:
page.component:

async presentModal(event) {
    const modal = await this.modalController.create({
      component: NewOptionsModalComponent,
      componentProps: {
        data: event.coords
      }
    });
    return await modal.present();
  }

firstModal.component:

async close() {
    await this.modalController.dismiss();
  }

  async presentSpotModal() {
    this.close();
    const modal = await this.modalController.create({
      component: SecondModalComponent,
      componentProps: {
        data: this.data
      }
    });
    return await modal.present();
  }

SecondModal.Component:

async close(data) {
    await this.modalController.dismiss(data);
  }

Viewing all articles
Browse latest Browse all 230975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>