navCtrl.pop don't work


#1

It does not leave the CadastroPage page for the LoginPage page, but it goes from LoginPage to registerPage correctly. I used this code:

login.ts (This is my rootPage)
import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;

/* Páginas */
import { CadastroPage } from '../cadastro/cadastro';

/*
  Generated class for the Login page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-login',
  templateUrl: 'login.html'
})
export class LoginPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {}

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

  /* Transição de Páginas */
  nextCadastroPage() {
    this.navCtrl.push(CadastroPage);
  }

}

cadastro.ts
import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;

/* Páginas */
import { LoginPage } from '../login/login';

/*
  Generated class for the Cadastro page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-cadastro',
  templateUrl: 'cadastro.html'
})
export class CadastroPage {

  constructor(public navCtrl: NavController, public navParams: NavParams) {
    /* Transição de Página */
    this.navCtrl.setRoot(CadastroPage);
  }

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

  /* Transição de Página */
  nextLoginPage() {
    this.navCtrl.pop(LoginPage);
  }

}

#2

i think the pop action does not take a Page Class as a parameter…

you should read carefully read the documentations first.

Ionic implements a stack-history --> each push pushs the component on top of the stack. Each pop pops the last one off the stack.