bug: navController.push wont fire
Type: bug
Ionic Version: 2.x (beta2)
Platform: android 5.1 webview
When trying to push a new page via navController after having popped the same page via navController then pushed page won't display.
The page that is being popped and then pushed again is a tabbed page.
Here is the sample code:
this._navController.pop({ animate: false }).then(() => { this._navController.push(TabsPage); });
If just simply pushing the same page again without trying to close the previous one then it works, but then also the old page underneath is not closed.
I also noticed that when using device back button on tabbed page then it won't pop the page as the back button in header does but actually minimizes the app and when resumes then the app is restarted.
Same logic used to work with beta1 release but not with tabbed page but with simple page.
So you're animating out, and back in the exact same page? Does it work when you animate out Page1, and animate in Page2?
Animating in a different page didn't work either. I even tried just pushing in the same page without popping. It kinda worked. It didn't open a new page, but did refresh the current page, except tabs header title. I kinda found out the problem also. I'm currently injecting NavController into one of the tabs content page and trying to do the things there but if I inject the NavController to root tabs page (the page that sets up tab contents) and using that NavController reference to pop and push then everything works as expected.
I also noticed in beta1 that I had to do certain things in tabs root NavController rather than in tabbed page NavController because back then when I tried to pop and push then it only popped the currently selected tab's content page and pushed the new page into the selected tab which was weird. Resulting in double layer of tab selections.
The problem here seems to be that NavController does not retain the context within tabbed page. Not sure if it is a desired behavior.
Would you be able to recreate this in a plunker? That would help us debug the issue, thanks: http://plnkr.co/edit/TW20lftdc5s622pcJPkp?p=info
I think its not a bug but a feature since tabbed pages seem to have a NavController with a different context. And like I said, I managed to get around the issue when I did my navigation stuff from the root tab page rather than from content tab page.
Just wanted to chime in here real quick - I've also encountered similar problems. This is my current workaround:
// in home.ts (the root page)
onPageWillEnter() {
if (loggedIn) {
// BlankPage is a really dirty hack to force ionic to trigger a nav.
// After upgrade to beta4, setPages doesn't really do anything.
this.nav.push(BlankPage);
this.nav.setPages([{page: DashboardPage}]);
}
}
BlankPage source:
import {NavController, Page} from 'ionic-angular';
@Page({
template: '<ion-content></ion-content>'
})
export class BlankPage {
}
Version info:
Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.4
Ionic CLI Version: 2.0.0-beta.24
Ionic App Lib Version: 2.0.0-beta.14
ios-deploy version: 1.8.5
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v5.8.0
Xcode version: Xcode 7.3 Build version 7D175
I'll spend a few minutes attempting to recreate a plunkr, but no guarantees.
Sorry, can't seem to repro in a clean environment. It definitely used to work 2.0.0-beta.3 though
@wli @ErkoKnoll Thanks for all the info! Is this still a valid issue? @wli You cant repro the issue anymore correct?
@jgw96 I can repro in my application 100%, but unfortunately I can't get it to trigger in Plunkr. There is still some kind of bug here (I'm not ruling out something being wrong in my application, but the addition/removal of the extra this.nav.push(BlankPage) line triggers different behavior).
@wli Are you using beta.4? Could you run ionic info from in your app directory and post the output here? Thanks!
Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.4
Ionic CLI Version: 2.0.0-beta.24
Ionic App Lib Version: 2.0.0-beta.14
ios-deploy version: 1.8.5
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v5.8.0
Xcode version: Xcode 7.3 Build version 7D175
Here's a small bit of more info. You can see that DashboardPage was triggered (page created, bindings exist, but not rendered into the viewport), but the HomePage is still there.

Note: the same thing happens if I change the call to this.nav.push(DashboardPage) (instead of setPages), so I do believe this is the same (or very similar) bug that was originally discussed here.
I'm having a similar problem, the navController.push works using Ionic serve and gets forwarded to the second page. But when uploading the application to Ionic View ( ionic upload) the navigation doesn't work anymore.
Page 1
alert("This fires"); this.navController.push(NewsDetailPage, { item: item, icon:categoryIcon, name:categoryName }); alert("This fires");
Page 2
export class NewsDetailPage { navController:NavController; navParams:NavParams; newsItem:NewsItem; categoryIcon:string; categoryName:string; constructor(navController:NavController,navParams:NavParams){ alert("This does not fire in Ionic View"); }}
@wouterDumon @wli could you test this with beta.6? There was some weirdness with zone.js in beta.4 that may have been causing some issues.
@jgw96 We just updated from beta.5 to .6 but still the same problem
@jgw96 Still a problem in beta6.
Here's my updated ionic info
Cordova CLI: 6.1.1
Ionic Framework Version: 2.0.0-beta.6
Ionic CLI Version: 2.0.0-beta.25
Ionic App Lib Version: 2.0.0-beta.15
ios-deploy version: 1.8.5
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v5.8.0
Xcode version: Xcode 7.3 Build version 7D175
and package.json
{
"dependencies": {
"angular2": "2.0.0-beta.15",
"angular2-moment": "^0.4.3",
"es6-promise": "3.0.2",
"es6-shim": "0.35.0",
"ionic-angular": "^2.0.0-beta.6",
"ionic-native": "^1.1.1",
"ionicons": "3.0.0-alpha.3",
"reflect-metadata": "^0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.6.10"
},
"devDependencies": {
"del": "2.2.0",
"gulp": "3.9.1",
"gulp-preprocess": "^2.0.0",
"gulp-watch": "4.3.5",
"ionic-gulp-browserify-typescript": "^1.0.1",
"ionic-gulp-fonts-copy": "^1.0.0",
"ionic-gulp-html-copy": "^1.0.0",
"ionic-gulp-sass-build": "^1.0.0",
"ionic-gulp-scripts-copy": "^1.0.0",
"run-sequence": "1.1.5",
"typescript": "1.8.9"
},
"name": "boost",
"description": "boost: An Ionic project",
"cordovaPlugins": [
"cordova-plugin-whitelist",
"cordova-plugin-x-toast",
"cordova-plugin-statusbar",
"cordova-plugin-app-version",
"cordova-plugin-splashscreen",
"cordova-plugin-device",
"cordova-plugin-console",
{
"id": "phonegap-plugin-push",
"locator": "phonegap-plugin-push",
"variables": {
"SENDER_ID": "XXXXXXXXX"
}
},
"cordova-plugin-crosswalk-webview",
"cordova-plugin-badge",
"cordova-plugin-app-event"
],
"cordovaPlatforms": [
{
"platform": "ios",
"version": "4.1.0",
"locator": "[email protected]"
},
"android",
{
"platform": "android",
"version": "",
"locator": "android"
}
]
}
@wli So i am trying to reproduce this in a clean, fresh project, but cant seem too. I read above that you cant seem to reproduce this in a fresh environment either, is that still the case?
@jgw96 Correct, I can't repro in a clean environment (on plunkr at least). I haven't tried with a local build yet.
@wli Would you mind trying it with a fresh local build when you get a chance and see if you still get the same issue? I cant seem to repro it locally.
@jgw96 I'd love to, but I'm extremely busy this week. Might have to wait until next week.