How to override the setRoot refresh upon re entering a page

When the user views the home screen for the first time - they are being sent there via this.nav.setRoot(Page). This presents an issue when I have three other pages settings root to a page. For example - I go to the home page, which is set root, so that home page data is loaded initially for the first time. Then the user navigates to the message page. Then the user goes back to the home page, the data is reloaded again. I don’t want that to happen. I would like to only call it once, but due to setRoot, it refreshes the page. Just like how navCtrl.push(Page) and .pop, the data is not refreshed. I have a hamburger navigation style and that’s why I have the set roots for each page in the hamburger navigation.

app.comp.ts

openPage() {
    this.nav.setRoot(Page);
  }
  openPageTwo() {
    this.nav.setRoot(MessagesPage);
  }

How do I override the nav.setRoot refresh? Or use something else entirely?

Thanks

1 Like