Caching view in ionic not working for first time


#1

I am working on an app that I am building from the ionic framework.
I have a three tabbed view.

  1. list
  2. filter
  3. tab3

The scenario is for the first time when I go to list state from filter state and then I select one item from the list and go the list detail page and I click on the back button from detail, this time I go back to list page but the list reloads means the state reloads.

But If I do this for the second time the list doesn’t reload and the state cache has been saved properly.

It only happens for the first time. I don’t know what could be the reason can anyone help me with this?

.state('app', {
      url: '/app',
      abstract: true,
      templateUrl: 'menu.html',
      controller: 'AppCtrl'
    })
    .state('app.parentTab', {
      url: '/parent',
      cache: true,
      views: {
        'menuContent': {
          templateUrl: 'parent.html',
          controller: 'parentCtrl'
        }
      }
    })
    .state('app.parentTab.list', {
      url: '/list',
      cache: true,
      views: {
          'search-units': {
            templateUrl: "list.html",
            controller: 'listCtrl'
          }
        },
    })
    .state('app.parentTab.listFilter', {
      url: '/listFilter',
      authRequired: false,
      cache: true,
      views: {
        'search-filter': {
          templateUrl: "filter.html",
          controller: 'filterCtrl'
        }
      },
    })
    .state('app.parentTab.tab3', {
      url: '/tab3',
      cache: false,
      views: {
        'search-map': {
          templateUrl: "tab3.html",
          controller: 'tab3Ctrl'
        }
      },
    })
    .state('app.detail', {
      url: '/detail',
      cache: false,
      views: {
        'menuContent': {
          templateUrl: "details.html",
          controller: 'detailsCtrl'
        }
      },
    })

#2

Hi,

i’ve noticed a similar problem… the first time a view is displayed, it doesn’t seem to be cached. After that it seems to be cached properly…

I’m using Ionic 1, with the latest ionic cli and cordova versions.


#3

Also in my case I’m using a tabs application. Displaying a tab view for the first time (for instance the list result of a search query) and navigating to a detailed view from this tab, then going back to the original tab, the tab view is resetted, and in debug mode, I can notice that the controller is called again.

The second time I navigate to a detailed view from this tab (after another research and populating a list), when I go back, it’s ok, my result list is still here.


#4

@toufic_zayed if you came across any solution let us know.


#5

I’m still facing this issue. Anyone who finally work around this situation?


#6

anyone who managed to solve this? still I am having this bug… it really annoys me… Thanks


#7
 .state('app.parentTab', {
      url: '/parent',
      cache: true,
      abstract: true, // <--- add
      views: {
        'menuContent': {
          templateUrl: 'parent.html',
          controller: 'parentCtrl'
        }
      }
    })