Tab page lifecycle events

I have a simple set of pages controlled by a parent component.

import {Component} from '@angular/core';
import {HomePage} from '../home/home';
import {ContactPage} from '../contact/contact';

@Component({
  template: `
  <ion-tabs>
      <ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="home"></ion-tab>
      <ion-tab [root]="tab2Root" tabTitle="Contact" tabIcon="contacts"></ion-tab>
  </ion-tabs>
  `
})
export class TabsPage {

  private tab1Root: any;
  private tab2Root: any;

  constructor() {
    this.tab1Root = HomePage;
    this.tab2Root = ContactPage;
  }
}


When tab 2 is selected it displays the contact page, which has a ionViewDidEnter function.
This function is only ever called once, the first time the contact page is viewed, navigating back to the home page, and then returning to the contact page does not trigger the ionViewDidEnter function.

What lifecycle event should I be using to get notified whenever the contact page gets displayed/activated?

5 Likes

Hi there, may I know if you figured out what lifecycle event should be used to get notified whenever the tab page being enter on the 2nd time and above?

Thanks

I have the same question here

You could use the ionViewWillEnter lifecycle event inside the Contact page.