# How to reload page every time click on tabs?

**URL:** <https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947>\
**Category:** ionic-v3\
**Created:** [December 20, 2017, 9:13am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947 "2017-12-20T09:13:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cooldp007](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@cooldp007](https://forum.ionicframework.com/u/cooldp007)\
**Post date:** [December 20, 2017, 9:13am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/1 "2017-12-20T09:13:33Z")

</div>

My problem is when i click on first tab then page reload but when i click second time on same tab means first tab that time page not reload

so i want to give me solution that every time page should reload

please help me

---

<div class="post-metadata">

**Author:** ![MattE](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/matte/32/66712_2.png) [@MattE](https://forum.ionicframework.com/u/MattE)\
**Post date:** [December 20, 2017, 10:12am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/2 "2017-12-20T10:12:36Z")

</div>

Use the ionViewWillEnter lifecycle event on your page.  
You can put the correct code in that method to refresh all the necessary things on your page.

–\> [https://ionicframework.com/docs/api/navigation/NavController/](https://ionicframework.com/docs/api/navigation/NavController/)

---

<div class="post-metadata">

**Author:** ![cooldp007](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@cooldp007](https://forum.ionicframework.com/u/cooldp007)\
**Post date:** [December 20, 2017, 12:31pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/3 "2017-12-20T12:31:12Z")

</div>

Thank you so much @MattE

It works for me

---

<div class="post-metadata">

**Author:** ![dilipkumar1007](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dilipkumar1007](https://forum.ionicframework.com/u/dilipkumar1007)\
**Post date:** [July 9, 2018, 6:46am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/4 "2018-07-09T06:46:44Z")

</div>

Hi @MattE my view page code is as  
  
\<ion-tab [root]=“tab1Root” tabTitle=“My Rx” tabIcon=“ios-medical-outline”\>  
\<ion-tab [root]=“tab2Root” tabTitle=“Search” tabIcon=“search”\>  
\<ion-tab [root]=“tab3Root” tabTitle=“Settings” tabIcon=“ios-settings-outline”\>

ion-tabs selectedIndex=“1”

my ts page is ::

import { Component } from ‘@angular/core’;  
import { HomePage } from ‘…/home/home’;  
import { MyRxPage } from ‘…/my-rx/my-rx’;  
import { SettingsPage } from ‘…/settings/settings’;  
import { NavController, LoadingController, Select, RadioButton } from ‘ionic-angular’;

@Component({  
templateUrl: ‘tabs.html’  
})  
export class TabsPage {  
tab1Root = MyRxPage;  
tab2Root = HomePage;  
tab3Root = SettingsPage;  
constructor(public navCtrl: NavController) {  
}  
}

Sir, I want in a way that, when I’ll click on any tab, concern page should reload accordingly.  
Please help me

---

<div class="post-metadata">

**Author:** ![cooldp007](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@cooldp007](https://forum.ionicframework.com/u/cooldp007)\
**Post date:** [July 9, 2018, 7:00am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/5 "2018-07-09T07:00:12Z")

</div>

Hello, @dilipkumar1007

Just write your main code( that reflect when page loads )inside ionViewWillEnter() in MyRxPage,HomePage,SettingsPage

---

<div class="post-metadata">

**Author:** ![vasanthb](https://avatars.discourse-cdn.com/v4/letter/v/4da419/32.png) [@vasanthb](https://forum.ionicframework.com/u/vasanthb)\
**Post date:** [July 9, 2018, 7:09am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/6 "2018-07-09T07:09:37Z")

</div>

If there is a sub page of the root page and you navigate back to root page from it, then ionViewWillEnter() is not triggering for me.  
Ex: HomePage has button on click it goes to user page. Now if I hit back from user page it will redirect to HomePage but ionViewWillEnter is not getting triggered. This happens only with tabs, for normal pages it is getting triggered.

---

<div class="post-metadata">

**Author:** ![dilipkumar1007](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dilipkumar1007](https://forum.ionicframework.com/u/dilipkumar1007)\
**Post date:** [July 9, 2018, 7:31am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/7 "2018-07-09T07:31:02Z")

</div>

@cooldp007

Thnx for your kind support, It works for me

---

<div class="post-metadata">

**Author:** ![cooldp007](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@cooldp007](https://forum.ionicframework.com/u/cooldp007)\
**Post date:** [July 9, 2018, 7:38am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/8 "2018-07-09T07:38:02Z")

</div>

Hello, @vasanthb

Please post your home page code

---

<div class="post-metadata">

**Author:** ![vasanthb](https://avatars.discourse-cdn.com/v4/letter/v/4da419/32.png) [@vasanthb](https://forum.ionicframework.com/u/vasanthb)\
**Post date:** [July 9, 2018, 7:53am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/9 "2018-07-09T07:53:42Z")

</div>

```auto
export class HomePage {
ionViewWillEnter(){
//calling an API
}
}

```

---

<div class="post-metadata">

**Author:** ![cooldp007](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@cooldp007](https://forum.ionicframework.com/u/cooldp007)\
**Post date:** [July 9, 2018, 7:55am UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/10 "2018-07-09T07:55:32Z")

</div>

Hello, @vasanthb  
it should work

---

<div class="post-metadata">

**Author:** ![gonzalogobea](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@gonzalogobea](https://forum.ionicframework.com/u/gonzalogobea)\
**Post date:** [October 2, 2018, 8:59pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/11 "2018-10-02T20:59:53Z")

</div>

ionViewWillEnter is not triggering for me either.  
Someone have a solution ?  
Thks.

---

<div class="post-metadata">

**Author:** ![dotman](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dotman/32/124290_2.png) [@dotman](https://forum.ionicframework.com/u/dotman)\
**Post date:** [October 19, 2018, 8:02pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/12 "2018-10-19T20:02:56Z")

</div>

Show your code lets see what you are doing

---

<div class="post-metadata">

**Author:** ![herveclaveau](https://avatars.discourse-cdn.com/v4/letter/h/c2a13f/32.png) [@herveclaveau](https://forum.ionicframework.com/u/herveclaveau)\
**Post date:** [November 24, 2018, 9:36pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/13 "2018-11-24T21:36:06Z")

</div>

In Ionic 4 with Angular router nothing above worked for me. I did find a way through watching the router and catching my tab URL when triggered.

```auto
  routerWatch() {
    this.routerSubscription = this.router.events.subscribe(
      (event: NavigationEnd) => {
        if(event instanceof NavigationEnd) {
          if(event.url == '/tabs/(jobs:jobs)')
            this.jobs = null;
            this.getJobs();
        }
      }
    );
  }

ionPageWillLeave() {
    this.routerSubscription.unsubscribe();
}

```

make sure to Unsubscribe on ionPageWillLeave or ionPageDidLeave or you will end up with a massive memory leak.

---

<div class="post-metadata">

**Author:** ![gemcomputers](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/gemcomputers/32/112710_2.png) [@gemcomputers](https://forum.ionicframework.com/u/gemcomputers)\
**Post date:** [December 5, 2018, 8:35pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/14 "2018-12-05T20:35:41Z")

</div>

Thank you for this! Used your method and it is working for me.

Surely ionViewWillEnter() should fire when coming back to a tab…? I hope the Ionic team addresses this at some point.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [December 5, 2018, 8:49pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/15 "2018-12-05T20:49:09Z")

</div>

> [@gemcomputers](#):
>
> Surely ionViewWillEnter() should fire when coming back to a tab

You can make a case for this position, but I think it’s miles from “surely”. In any event, as a defensive programmer I think the most prudent approach is to assume nothing about willEnter/willLeave events aside from the fact that they come in pairs: you will never get two of the same kind in a row.

---

<div class="post-metadata">

**Author:** ![herveclaveau](https://avatars.discourse-cdn.com/v4/letter/h/c2a13f/32.png) [@herveclaveau](https://forum.ionicframework.com/u/herveclaveau)\
**Post date:** [December 15, 2018, 6:08pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/17 "2018-12-15T18:08:53Z")

</div>

It does not in Ionic 4, not a single page event fires when navigating from one tab to another.

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [December 15, 2018, 7:10pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/18 "2018-12-15T19:10:59Z")

</div>

> [@herveclaveau](#):
>
> not a single page event fires

I said all you can rely on is:

> you will never get two of the same kind in a row.

If you don’t get any, isn’t that still true?

---

<div class="post-metadata">

**Author:** ![herveclaveau](https://avatars.discourse-cdn.com/v4/letter/h/c2a13f/32.png) [@herveclaveau](https://forum.ionicframework.com/u/herveclaveau)\
**Post date:** [December 21, 2018, 7:45pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/19 "2018-12-21T19:45:10Z")

</div>

Even with my router watch I end up with memory leaks. This page caching is garbage, Im removing Tabs altogether and adding tabs manually to every page.

---

<div class="post-metadata">

**Author:** ![YoSoY](https://avatars.discourse-cdn.com/v4/letter/y/9dc877/32.png) [@YoSoY](https://forum.ionicframework.com/u/YoSoY)\
**Post date:** [April 17, 2019, 2:53pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/20 "2019-04-17T14:53:23Z")

</div>

If doesn´t work **ionViewWillEnter()**  
Force refreshing with: **this.navCtrl.setRoot(this.navCtrl.getActive().component);**

---

<div class="post-metadata">

**Author:** ![alitalaee](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@alitalaee](https://forum.ionicframework.com/u/alitalaee)\
**Post date:** [July 1, 2020, 4:57pm UTC](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947/21 "2020-07-01T16:57:01Z")

</div>

Hi in Ionic 5 I solved this problem,  
in  
tabs.html file::

\<ion-tabs #tabs (ionTabsWillChange)=“gets(tabs)”\>

 {{'home' | translate}} 

in tabs.ts file :::  
gets(tab: IonTabs) {  
if ("/tabs/" + tab.getSelected() != this.router.url) {  
this.router.navigateByUrl(“tabs/” + tab.getSelected());  
}  
}

this code worked for me. when tab selected if in children route , reload page.

[Next page](https://forum.ionicframework.com/t/how-to-reload-page-every-time-click-on-tabs/115947.md?page=2)
