From page1 I used nav.push(page2) to come to page2.
In page2 on click of a button I want to move to page3 and then remove page2 from the nav stack.
So that the nav stack is page1 =>page3 and when the user clicks back on page3 it comes to page1.
My current working solution is to do this.
navCtrl.pop().then(()=>{
navCtrl.push(page3);
})
The only problem is the that the transition goes like this page2 => page1 =>page3. I would not have bothered about this if this was not visible. But this transition is visible.
Any other variation I tried either breaks the nav in the the page or disables the back button on the navBar thats created using menuToggle.
Can some one suggest a way to effectively deal with this requirement.
The problem with that approach is that I don’t know my index number. And navCtrl.getPrevious or navCtrl.getViews fails in the then() because the navCtrl is still transitioning.
I attempted to do this in the Page3’s ionViewWillEnter().
But in popover, this.navCtrl.getActive() is undefined…
Then i tried this :
pushParamsPage(){
if ( this.navCtrl.canGoBack()) {
console.log('can go back true');
this.viewCtrl.dismiss('popover').then(() => {
this.app.getRootNav().push('ParamPage').then(() => {
this.navCtrl.remove(1, 1);
}); //we push from RootPage and not from PopoverNav, allow to use BackButton
});
}
else {
console.log('can go back false');
this.viewCtrl.dismiss('popover').then(() => {
this.app.getRootNav().push('ParamPage');
});
}
}
But this.navCtrl.canGoBack() is false even if i’m not in the rootpage… Don’t understand why…
I use this before finding a solution, but we see the transition :