caching - ionic 缓存不起作用

标签 caching ionic-framework

我正在使用 Ionic 开发一个应用程序,但缓存未按预期工作。 每次我从 root.home.notifs 切换到 root.home.chats 时,chats View 都会刷新(其 Controller 会重新初始化)。

我有 2 个标签:

  <ion-footer-bar>
    <ion-tabs class="tab-bottom tabs-striped">
      <ion-tab icon="ion-ios-chatboxes-outline" ui-sref="root.home.chats">
      </ion-tab>
      <ion-tab icon="ion-ios-heart-outline" ui-sref="root.home.notifs">
      </ion-tab>
    </ion-tabs>
  </ion-footer-bar>

这些状态(我的 Controller 是空的):

.state('root.home', {
  abstract: true,
  cache : true,
  url: '/home',
  templateUrl: 'components/home/templates/home.html'
})
.state('root.home.chats', {
  url: '/chats',
  cache : true,
  controller: 'ChatCtrl',
  templateUrl: 'components/home/templates/home.chats.html'
})
.state('root.home.notifs', {
  url: '/notifs',
  cache : true,
  controller: 'NotifCtrl',
  templateUrl: 'components/home/templates/home.notifs.html'
})

每个 View 都有cache-view="true",我已经通过这种方式配置了缓存$ionicConfigProvider.views.maxCache(100)

注意:我注意到此错误取决于我首先导航到哪个状态。有一个调用 $state.$go('root.home.notifs') 的身份验证系统。更改此设置会更改正确缓存的 View

有什么解决这个问题的建议吗?

最佳答案

尝试使用它来缓存前向 View $ionicConfigProvider.views.forwardCache(true);

关于caching - ionic 缓存不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38475405/

相关文章:

javascript - ng-circle-progress 组件仅在属性 render OnClick 属性设置为 true 时才起作用

ionic-framework - ionic2 货币格式在设备上损坏

python - Python 对象的唯一表示

ruby-on-rails - 有没有办法缓存 .all 调用?

安卓缓存框架

ios - 导出文件 : No 'teamID' specified and no team ID found in the archive

延迟加载图像的 Android 内存不足错误

caching - html5 缓存 -> "network: *"不起作用

css - 如何使 Ionic 中的导航栏(ion-nav-bar)透明?

ios - cordova - 如何禁用 ios 的方向颠倒?