If you find yourself already on the particular page, instead of designating it as Root, consider utilizing Nav Guards
In certain scenarios, a developer may need to manage views entering and
exiting. In order to facilitate this, NavController offers the ionViewCanEnter and
ionViewCanLeave methods. These methods are akin to Angular 2 route guards, but they are
more seamlessly integrated with NavController.
For instance, if we need to confirm that a service has begun but hasn't completed yet, and restrict the user from navigating away until the service finishes.
To achieve this, employ code similar to the following:
// Procedure executed when the user attempts to leave the page
ionViewCanLeave() {
if(this.serviceHasStarted && !this.serviceHasFinished) {
let showAlertMessage = this.alertCtrl.create({
title: 'Error',
message: 'You cannot proceed until ...',
buttons: [
{
text: 'Ok',
handler: () => {
}
}]
});
showAlertMessage.present();
// Return false to block the user from leaving the page
return false;
} else {
// Return true to permit the user to navigate away
return true;
}
}