ionic-framework: [ionicPage] URL does not update when pushing new pages through navController

Ionic version: (check one with “x”) [ ] 1.x [ ] 2.x [x] 3.x

I’m submitting a … (check one with “x”) [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior: In main page, it has its own ion-nav and a child page dashboard will be pushed into it. When I trying the push another page in main page through the NavController, the URL does not change. But it does changed when using setRoot method. In both case, the page is changed correctly.

Expected behavior: The URL will be changed accordingly with the nav push method.

Related code:

app.component.ts

@Component({
    template: `<ion-nav #rootNav [root]="rootPage"></ion-nav>`
})
export class MyApp {

    public rootPage = 'LoginPage';
    constructor( ) {
    }
}

Login.ts

@IonicPage({
    segment: 'login'
})

@Component({
 ...
})

export class LoginPage {

    public nav: NavController;

    constructor( navCtrl: NavController ) {
        this.nav = navCtrl;
    }

    gotoMain() {
        this.nav.setRoot( 'MainPage' );
    }

}

main.ts

@IonicPage({
    segment: 'main'
})

@Component({
    selector: 'page-main',
    template: `
      <ion-header>
          <app-header (onMenuClick)="changeView( $event )"></app-header>
      </ion-header>

      <ion-content>
        <ion-nav #content></ion-nav>
      </ion-content>

    `
})

export class MainPage {

    @ViewChild( 'content' ) content;

    public nav: NavController;

    constructor( navCtrl: NavController ) {
        this.nav = navCtrl;
    }

    ngOnInit() {
       this.content.push(  'DashboardPage'  );
    }

    private changeView( pageName ){

        this.nav.push( pageName ); ---> the URL does not change

        this.nav.setRoot( pageName ); ---> the URL has changed correctly

    }

}

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Cordova CLI: 6.5.0
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.6
ios-deploy version: 1.9.1
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v6.3.1
Xcode version: Xcode 8.3.2 Build version 8E2002

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (1 by maintainers)

Most upvoted comments

Hello, Any progress on this issue?

Thanks

I get this to work just changing the push parameter to the name of the page i was doing this this.navCtrl.push(page); and the url was not updating i changed to this.navCtrl.push(page.name); and it worked for me

I got the same error, did someone try anything to fix this?

@erperejildo - I was able to get this working by enabling Deep Links: https://ionicframework.com/docs/2.0.1/api/navigation/DeepLinker/

Hello, thanks for using Ionic. Could you post a repo we could use to reproduce this issue?