Refresh tabs

Hi!

I want to know if there is a way that i can refresh a tab by only clicking on it again, i’ve tried with ng-class but i keep getting infinite loop on the digestive iteration.

Can someone help me please?

@mhartington

Hey there!

So what do you mean refresh?

This view has data from a server, what i want is that when i click on the tab icon again, the view get refreshed, maybe reload? or try to pull data from the server once again.

Oh yeah, you could do that.

Hey mike, i have tried that, but doesnt really work, lets say you switch to the about tab, if you try to go to the home tab again it wont go there, it will try to refresh.

no solution to this problem?

Hey sorry, was away from my computer during the weekend.

You can put to some logic together to check on what tab index you are on, if your not on the current tab needed, you can just navigate normally. But if you are on the tab needed, do a refresh

your example works awesome, but when i try it the tab appears empty and the url doesn’t change, i’m not getting any error on the console.

oops, fixed it

$ionicTabsDelegate.select(2, true)

Thank you very much @mhartington

1 Like

Hello @mhartington, I think I am facing the same thing. Say for example I have a view named “tab.settings”. Inside this view I am controlling the user data and profile updating of the user. So I have two buttons “login” and logout. When the user data is shown also the button logout is shown and vice versa. So when the user clicks logout I want the view to automatically hide the logout button and show the login button and hide the user data.

I know that I will put this in any item I want to hide if there is no user logged in: ***ng-show="{{user}}"***.
And opposite is : ***ng-show="{{!user}}"***. But the problem I have to manually refresh my browser for these to take effect and the reason is : the view is cached.

Use the view events.

http://ionicframework.com/docs/api/directive/ionView/

@mhartington I don’t know where to ask this question, but its a little close to what I am trying to do, i appreciate if you can guide me to the right directions

I have the tabs app, under each tab there are few more screens. so tab1 has a, b and c screens

so from tab1 when I click a button i go to screen a, and when click another button I go to screen b and so on…

when I click on button a I land on screen a just fine, at this stage the tab1 is active.

now for my questions. When I am in screen a and tap on tab1 since tab1 is the root i need to land on the tab1’s main screen. I am unable to do this, can you help please.

when i place ng-click=“someFunction()” and try to handle the event there, nothing happens… since i have already landed on screen a, and screen a has a controller handling all the functionality there… hope this explains.

can you help please!

Hello ,
The Simplest way to refresh the tab is to add cache-view="false" in ion-view

3 Likes

@IlexSquare : This seems to be only applicable Ionic1 not Ionic2 :frowning:

Wow! Problem fixed in the tabs pages… whichever one would like to refresh everytime
just replace ngOnInit() with ionViewDidEnter()

3 Likes

this works better for tab refresh everytime… thank a lot :slight_smile:

Thanks! IonViewDidEnter() { // observable http response } re-acquiring the http data for each change in the data.