Not saving certain views in ionicHistory

Hey there,

Is it possible to specify in the stateProvider what views should not be remembered by ionicHistory?
Imagine the following scenario:

  1. User is on a page (state 1)
  2. User navigates to other page (state 2)
  3. User clicks a button that leads to a new submit-form page (state 3)
  4. User submits the form and app redirects to previous page (state 2)
  5. User clicks back-button to return to state 1, but instead the app goes back to state 3 because it’s in the ionicHistory

Any ideas would be appreciated. :blush:

I did this last week, the solution I found was this. Instead to redirects to state 2 after submit the form I used goBack method from $ionicHistory.

Take a look here at docs.$ionicHistory/

Then after used go back when the user clicks on the back button on stage 2, it redirects to the right state (state 1).

yep and you can set cache-view=“false” on your ion-view element.

@bengtler I never tried, but I don’t think cache will solve his problem, since the problem is with the logic of the navigation. If you remove the cache of the view and do the same flow of navigation that he is talking everything was flowing like he wants? Did you try?

i meant this as a addition to your correct answer because you do not need to hold views in the cache you do not have in the history ;).

1 Like

Thanks for your reply, using goBack is a good idea but it’s not quite an ideal solution to the problem. But if there’s no alternative I think this will have to do. Thanks!

@bengtler SURE!! you’re right, forgot that, great point. :clap: