Controller not reloading when navigating between states

I’m having a bit of trouble understanding Ionic’s navigation logic.

I am developing a workflow where users need to add items to a list. The workflow is as follows:

  1. Start on the list page (page 1).
  2. Navigate to a selection page and select an item (page 2).
  3. Customize the item (page 3).
  4. Return to the list page to see the item added to the list (page 1).
  5. Repeat as many times as necessary.

The problem is that when I loop through the workflow a second time, my selections from the first time around are cached in the pages 2 and 3. I have created an example to simulate this effect:

Try doing the following:

  1. Enter 1 in the grey textbox on the first page
  2. Click “Transition 2”
  3. Enter 2 in the grey textbox on the second page
  4. Click “Transition 3”
  5. Enter 3 in the grey textbox on the third page.

Once you’ve done this, if you click “Transition 1” to return to the first page “1” is still present in the textbox. If you click through to pages 2 and 3, their values are still present as well.

What I would have expected to happen would be to receive a fresh copy of page 1 when I loop back, because I am navigating forward to page 1 with $state.go("1"). Is this assumption incorrect, and if so, how can I make it such that when I navigate from page 3 to page 1, I get a fresh version?

Hi @Levi Ionic beta 14 added caching and “disconnecting” of scopes instead of destroying and reloading.

There are directives which can be used to force caching off in certain views, I suggest you take a look at the documentation around beta 14, which was a major update :smile:

Good luck!

1 Like

Fantastic that solved my problem. Good to know coming from an Angular background. Thanks!

Only a pleasure Levi, good luck man :smile: