Reload state in Ionic 2


#1

how to fetch fresh data(raw/ http) each time i click on the ion-tab?
this is how ionic 1 but dont how to do it in ionic 2/angular 2

      $stateProvider.state('myState', {
       cache: false,
       url : '/myUrl',
       templateUrl : 'my-template.html'})

how do i apply it in the nav.push or nav.setRoot? I want to fetch/reload new data each time i view the page or i click on the ion-tab.


#2

i am not into it, but a tab is connected to an ion-nav. So you can listen in your tab-class (Page) on the page lifecycle hooks like the $ionicView-events in ionic 1.

Search for lifecycle. there you can use onPageWillEnter or onPageDidEnter to execute something every time you open the page :wink: