Doesn't work NavController pop method in Ionic 3


#1

I was built Ionic 3 application using following cli command.
```
$ ionic cordova start demo tabs -v3

And I opened one page with NavController push method in home page.
And I want to go back home page, so I click back button in navbar.
But I can't back to home page.
I was built Ionic 2 application before and it works fine, but I have updated the code, it doesn't work.
Who can solve this problem and help me?

#2

Please share your code


#3

Where did you find that command to start up a new project? That’s totally new to me.


#4

home.html

...
<ion-content>
... ... ...
           <!--Username-->
          <div style="margin-top: 3%;">
            <strong><a href="#" (click)="gotoProfilePage(response.username)">ProfilePage</a></strong>
          </div>
 </ion-content>

home.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

import { ProfilePage } from '../profile/profile';

@IonicPage()
@Component({
  selector: 'page-feed',
  templateUrl: 'feed.html',
})
export class HomePage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
  }
  
  gotoProfilePage(username: string){
    this.navCtrl.push(ProfilePage, {username: username});
  }

}

profile.html

<ion-header>

  <ion-navbar color="black">
    <ion-title>Profile Page</ion-title>
  </ion-navbar>

</ion-header>

<ion-content padding>
   ... ... ...
</ion-content>

profile.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

@IonicPage()
@Component({
  selector: 'page-comments',
  templateUrl: 'comments.html',
})
export class ProfilePage {

  username: string;

  constructor(public navCtrl: NavController, public navParams: NavParams) {
    this.username = this.navParams.get('username');
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad ProfilePage');
  }
}

This is my code snippets.
When I click the button called “ProfilePage” in Home Page, I can navigate to Profile Page.
And I can see back button in navbar in Profile Page.
But when I click that back button in navbar, I can’t back to Home Page.
Once I used this code on Ionic 2, it works fine.
I updated Ionic CLI version from 2.0.0 to 3.0.0, it doesn’t work.


#5

Check your console while clicking button to find the error. And post that error here, so then we can get an idea of your error.