ionic-framework: NavController.remove() doesnt work as expected.
Short description of the problem:
The NavController.remove function doesnt work as docs states. It cant remove pages in some cases when it should be able to.
What behavior are you expecting?
NavController.remove works as docs states and remove pages from the stack the correct way.
Steps to reproduce:
For testing you will have to expose the NavController in the last page with console.log. (In the constructor add console.log(this.nav));
We will use this code snippet to list the stack, because no built in options exist for it now at the moment.
[
(temp1.getByIndex(0))?temp1.getByIndex(0).instance:null,
(temp1.getByIndex(1))?temp1.getByIndex(1).instance:null,
(temp1.getByIndex(2))?temp1.getByIndex(2).instance:null,
(temp1.getByIndex(3))?temp1.getByIndex(3).instance:null,
(temp1.getByIndex(4))?temp1.getByIndex(4).instance:null,
(temp1.getByIndex(5))?temp1.getByIndex(5).instance:null,
]
- Push 5 pages to the stack. (The fifth element in the above snipets, confirms our stack is 5 element long.)
- In the last page run the code snippet above to check the stack
- Run the following code in the console:
temp1.remove(temp1.length() - 2, 2) - Check the stack with the snippet above, and notice that only the last element was removed from the stack not the last 2.
Note: This seems not to work only if I try to remove the last 2 page. With the last 1 or 3 it works well. So temp1.remove(temp1.length() - 1, 1) and temp1.remove(temp1.length() - 2, 2) produces the same result.
Which Ionic Version? 2.x
Run ionic info from terminal/cmd prompt: (paste output below)
Cordova CLI: 6.3.1
Gulp version: CLI version 1.2.2
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v6.3.1
Xcode version: Xcode 8.0 Build version 8A218a
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (7 by maintainers)
Thanks for the info everyone, this is fixed and will be in the next release.
same problem for me here. I have this code that worked on Beta11 but in RC0 it’s not working anymore.
this.nav.push(MyNextPage, params).then(() => { this.nav.remove(this.nav.getActive().index - 1, 1); });I tried to remove the nav.remove from inside the promise but it didn’t work either