Refresh ion-list when it loads


#1

I have a sign in page and a shopping list page. If I successfully sign in, I will go to shopping list page. The problem I have is the shopping list page still have the previous signed in user shopping list.

For example: User A sign in, shopping list page shows user A shopping list. User A sign out. User B Sign in, shopping list page still shows user A shopping list until user B “pull to refresh”.

I want to auto-refresh the shopping list page once if I go there. I use something similar to ionic refresher ( http://ionicframework.com/docs/api/directive/ionRefresher/ )

<ion-content ng-controller="MyController">
  <ion-refresher
    pulling-text="Pull to refresh..."
    on-refresh="doRefresh()">
  </ion-refresher>
  <ion-list ng-init="doRefresh()">
    <ion-item ng-repeat="item in items"></ion-item>
  </ion-list>
</ion-content>

How do I call doRefresh() when I transit from sign in to shopping list ? I have ng-init=“doRefresh()” inside , but it does not work.


#2

Search the forum about view caching.

There are several solutions which may depend on how you defined your state and controller.