Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

Ionic Modal is not passing data back

$
0
0

The problem is that data being sent back from modal is undefined.

The function I’m using to open my modal is below:

async openResultsModal() {

  this.ResultsPopover = await this.modalController.create({

    component: ResultsPage,

    componentProps: {

      gameMode: this.gameMode,

      Localresult: this.LocalGameResult

    },

    mode: "ios"

  });

  this.ResultsPopover.onDidDismiss().then((dataReturned) => {

   if (dataReturned !== null) {

    console.log(dataReturned.data);

  }

  });

  return await this.ResultsPopover.present();

}

However, This function is inside a service file and I am calling it in a timer like so:
The timer will need to stay

  setTimeout(() => 
  {
      this.openResultsModal();
  },
  1500);

My modal page is like this:

export class ResultsPage implements OnInit {
  gameMode;
  Localresult;

  constructor(navParams: NavParams, public modalController: ModalController) { 
    this.gameMode = navParams.get('gameMode'); 
    this.Localresult = navParams.get('Localresult'); 
  }

  ngOnInit() {
  }

  ionViewWillLeave(){
    this.closeModal();
  }

  async closeModal() {
    const onClosedData: string = "This is Data";
    await this.modalController.dismiss(onClosedData);
  }



}

The data that is returned to my service file is undefined. Is it because I am using the JavaScript setTimeout() function?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



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