3

I have an application tabs whit 4 Tabs, and each tab shows some data according to a configuration. The page have a header that contains a popover component with the settings option on it. After the user set some configuration on settings and back to some tab page, that page must refresh the content.

I am using the ionViewDidEnter or ionViewWillEnter lifecycle events and check if the previous settings have been changed but the event hasn't been being catch, only when I change to other tab page.

Tab page A

export class HomePage implements OnInit {
  ionViewDidEnter(){
    if(this.client.doClientChanged(this.clientName)){
      console.log("changed");
    }
    else{
      console.log("not changed");
    }
  }
  ionViewWillEnter(){
    console.log("test")
  }
}

Header component

export class PrimeHeaderComponent {
  constructor(public popoverCtrl: PopoverController) {}

  presentPopover(event: any) {
    let popover = this.popoverCtrl.create(MenuPage);
    popover.present({
      ev: event
    });
  }
}

Popover Component

export class MenuPage {

  constructor(
    public viewCtrl: ViewController, private navCtrl: NavController) {}

  openConfig(){    
    this.navCtrl.push(ConfigPage);    
  }
}

When I chose the configuration, I back to the previous page that still shows the popover, and when I dismiss the popover, nothing happen with the lifecycle events.

2
  • can you share a bit more what do you mean by configuration? is that pure data or is there any like css style changes etc? Commented Jul 31, 2018 at 23:56
  • Yes. It is pure data. I have a lot of users and the administrator can see anything about the user on the app, but I need to select one, two or more customer and then refresh the data. I've already solved the problem, I will post in a few hours.
    – jraspante
    Commented Aug 7, 2018 at 21:17

1 Answer 1

4

Use the .onDidDismiss() of the popover controller

let popover = this.popoverCtrl.create(MenuPage);

popover.onDidDismiss(() => {
  //your action here
});

popover.present({
  ev: event
});

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