Nav pop two pages back


#1

What’s the best way to pop back X pages ? We have landed on repeatedly calling pop with animate set to false. This works but it seems inelegant. If there’s a better way let me know. I tried the remove method but I couldn’t actually see that it did anything. While we’re discussing it, I am also curious if anyone has pages in their application representing a particular flow, that they call from multiple places in the app. Obviously you want the flow to complete and then return the user to the page they started. We haven’t found a great way to achieve this when the page we want them to go back to isn’t a root already.


#2
this.navCtrl.pop().then(()=>{
this.navCtrl.parent.navCtrl.pop()
});

I am just doing a wild guess just check if it works.


#3

Hi @shipps.

This work for me on ionic3 v3.3.0

this.navCtrl.push(
                            PresentationPreviewPage,
                            {
                                id : this.presentation._id
                            }
                        ).then(() =>  {
                            const startIndex = this.navCtrl.getActive().index - 2;
                            this.navCtrl.remove(startIndex, 2);
                        });

In Ionic 3 v3.5.0 this solution does not work and I’m looking for a better solution.


#4

@shipps

Wow, I found it!

const startIndex = this.navCtrl.getActive().index - 1;
                this.navCtrl.remove(startIndex, 2).then(() => {
                    this.navCtrl.push(
                        PresentationPreviewPage,
                        {
                            id : cloned_id
                        }
                    );
                });

#5

this.nav.pop().then(() => this.nav.pop());