You can implement such things using the Nav guard. You can find them in the ion docs for NavController .
An implementation might look something like this:
ionViewCanEnter(): Promise<any> { return new Promise((resolve, reject) => { let alert = this.alertCtrl.create({ title: 'Alert', message: 'Please confirm ...', buttons: [ { text: 'Cancel', role: 'cancel', handler: () => { reject(); }, }, { text: 'Confirm', handler: () => { resolve(); }, }, ], }); alert.present(); }); }
Use ionViewCanEnter() since ionViewCanLeave() does not currently work (at least when working with tabs).
David source share