1

I have a doubt about how can make this.

// Page 0.1
this.navController.pop(); 

// Page 0
ionViewWillEnter() {
  console.log("Im here");
}

I have a page that clicking a button I can go back to Page 0. But each time that I get back it doesn't enter inside ionViewWillEnter(). I need to enter to evaluate some new changes in data to print in screen. Any idea?

Environment:

Ionic CLI                     : 6.12.2
Ionic Framework               : @ionic/angular 5.5.1
@angular-devkit/build-angular : 0.1000.8
@angular-devkit/schematics    : 10.0.8
@angular/cli                  : 10.0.8
@ionic/angular-toolkit        : 2.3.3

2 Answers 2

2

There must be something else going on because it should always execute the ionViewWillEnter when it's about to enter to the page.

Please take a look at this Stackblitz demo

Demo

The code of the home page:

import { Component } from "@angular/core";
import { NavController, ViewWillEnter } from "@ionic/angular";

@Component({
  selector: "app-home",
  templateUrl: "./home.page.html",
  styleUrls: ["./home.page.scss"]
})
export class HomePage implements ViewWillEnter {
  constructor(private navController: NavController) {}

  ionViewWillEnter() {
    console.log("Will enter!");
  }

  public openDetailsPage(): void {
    this.navController.navigateForward("/details");
  }
}

And the details page:

import { Component } from "@angular/core";
import { NavController } from "@ionic/angular";

@Component({
  selector: "app-details",
  templateUrl: "./details.page.html",
  styleUrls: ["./details.page.scss"]
})
export class DetailsPage {
  constructor(private navController: NavController) {}

  public goBack(): void {
    this.navController.pop();
  }
}

0

May be I a am a little bit late to the party, but I had the same issue. And I was able to solve it by making sure that 2 routes are located in the same router outlet. If they are not, you will see routing animation, but component which you are leaving will persist in a DOM in other outlet.

Not the answer you're looking for? Browse other questions tagged or ask your own question.