ionViewCanEnter didn't work after pop()

Hi everyone ,

I have a tabs.

//icom-tab.html
<ion-tabs>
    <ion-tab [root]="dashboardRoot" tabTitle="DASHBOARD" ></ion-tab>
    <ion-tab [root]="scheduleRoot" tabTitle="SCHEDULE" ></ion-tab>
    <ion-tab [root]="todoRoot" tabTitle="TO DO LIST" ></ion-tab>
</ion-tabs>

in toDoRoot tab

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

@Component({
    selector: 'page-tab-todo-list',
    templateUrl: 'tab-todo-list.html',
})
export class TabTodoListPage {


  constructor(public navCtrl: NavController) {}

  LoadCheckOut() {
        // I will go to CheckOutConfirmationPage
        this.navCtrl.parent.parent.push(CheckOutConfirmationPage);
  }

  ionViewCanEnter() {
       // I want to run loadData() function 
       //after pop() from CheckOutConfirmationPage page
       console.log("Run ionViewCanEnter");
       this.loadData();
  }

  loadData() {
      // Do something
  }

}

in CheckOutConfirmationPage

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

@Component({
    selector: 'page-check-out-confirmation',
    templateUrl: 'check-out-confirmation.html',
})
export class CheckOutConfirmationPage {


  constructor(public navCtrl: NavController) {}

  goBack() {
        this.navCtrl.pop();
  }

}

When I use LoadCheckOut() to go to CheckOutConfirmationPage and goBack() to go back, after that ionViewCanEnter in TabTodoListPage didn’t work . I can’t run loadData() function to load the data again after pop from CheckOutConfirmationPage . ionViewCanEnter run well if I don’t use ion-tabs . What’s problem here ? Thank for any help.

Well when you pop , this life cycle hook definitely run ionViewWillEnter() put the code in this.
Try this.

I tried your solution, but It didn’t run ionViewWillEnter().

See: ionViewCanEnter doesn't work as expected

Thanks, but I could used pop and navigation. problem here, ionViewWillEnter() didn’t run after pop from another page.

1 Like