How to go back multiple pages in ionic 3

2019-08-19 05:41发布

问题:

I have the page flow like below:

A->B->C->D

Somehow I will do a function in page"D", after it need to go back page"B". How can I achieve that? Using .pop() just can go back one page. Using .push(B) is also not the solution, because the flow will become:

A->B->C->D->B

The solution I want is:

A->B

Anyone know how to achieve it? Thanks a lot.

回答1:

this.navCtrl.popTo(this.navCtrl.getByIndex(this.navCtrl.length()-(N+1)));

Where N is the number of pages that you want to go back.

So if you want to go back 2 pages N=2



回答2:

Try Using the popTo() method by giving the index of page in a parameter like below:

nav.popTo( this.navCtrl.getByIndex(1))