Disable view's cache in $state.go

Here is my scenario:

I have list view (with infinite scroll) - cache in router for that view is enabled.

After clicking item I go to detail view. In detail view I click button and trigger $state.go() to list view.
Ionic triggers navback and displays cached view - but I don’t want to - I have different params (not $stateParams) and I want to reload `list view``.

How to do it?

ui-router has third param for $state.go(view, params, options) where You can set reload=true and then it should reload state but it’s not working with ionic.
And I don’t want to disable cache for list view in router bacause of infinite scroll (I want to remember position for scrolling when clicking back).

Hi you can Disable cache for the entire app throught $ionicConfigProvider.views.maxCache(0); if u want to disable cache just or one view, u can do it as attribute <ion-view cache-view="false" view-title="My Title!"> ... </ion-view> or on your state provider config $stateProvider.state('myState', { cache: false, url : '/myUrl', templateUrl : 'my-template.html' })
here is the link for more info link I hope it can help you and sorry my terrible english

2 Likes

There are a lot of questions on the forum about reloading views, none of the ones I found mentioned using $ionicHistory.

$ionicHistory.clearCache().then(function(){
  $state.go('login');
});

It is disappointing that the ui-router reload option isn’t supported, and that lack of support isn’t documented. The method presented here provides a means to refresh a view without permanently disabling the cache for that view. It does clear cache for all views, not just the current view.

3 Likes

Like a champ!!!

$ionicLoading.show({template: Logout…’, duration: 2900});
$timeout(function() {
$ionicHistory.clearCache().then(function () {
$ionicLoading.hide();
$state.go(‘login’);
});
},3000);

How to do this in ionic 2?