Verthon
Verthon

Reputation: 3247

Ionic 3 How to display toast on modal?

Hello I have uncommon structure of creating activity. First OverviewPage user can open the modal, which after selecting one activity from list pushes to desired activityPage - activity creation page.

Once user leaves that page, submit new activity I use nav methods in that order

this.navCtrl.getPrevious().data.toastMessage = 'Added activity successfully';
this.navCtrl.pop();

After adding new activity it returns to OverviewPage with modal opened, unfortunatelly it doesn't reload that page so I cannot detect in ionViewWillEnter if I can show that popover.

if(this.navParams.data.toastMessage) {
 this.presentToast(this.navParams.data.toastMessage)
}

How can I change code to display that toastMessage in modal after creating new activity ? Thank you.

Upvotes: 0

Views: 396

Answers (1)

Verthon
Verthon

Reputation: 3247

So the solution was pretty simple, don't know if its recommended or not, but I left the presentModal functions inside of each activity and removed that part:

this.navCtrl.getPrevious().data.toastMessage = 'Added activity successfully';

So right now the last lines of activity creation are display toast and pop navigation stack and surprisingly it works great.

this.appFunctionCtrl.presentSuccessToast('Added activity successfully', 1500);
this.navCtrl.pop();

Upvotes: 1

Related Questions