离子缓存不起作用 [英] Ionic Caching not working

查看:112
本文介绍了离子缓存不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ionic开发应用程序,但缓存无法按预期工作。
每次从 root.home.notifs 切换到 root.home.chats 聊天查看已刷新(其控制器已重新初始化)。

I'm developing an app using Ionic, but caching isn't working as expected. Every time I switch from root.home.notifs to root.home.chats the chats view is refreshed (its controller is reinitialized).

我有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>

这些状态(我的控制器为空):

And these states (my controllers are empty):

.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'
})

每个视图都有 cache-view =true我以这种方式配置了缓存 $ ionicConfigProvider.views.maxCache(100)

Every view has cache-view="true" and I've configured the cache this way $ionicConfigProvider.views.maxCache(100)

注意:我注意到这个错误取决于我首先导航到哪个州。有一个auth系统调用 $ state。$ go('root.home.notifs')。更改此更改会更正哪个视图正确缓存

NOTE: I've noticed that this error depends on which state I navigate to first. There's an auth system that calls $state.$go('root.home.notifs'). Changing this changes which view is cached correctly

有关如何解决此问题的任何提示?

Any tip on how to solve this?

推荐答案

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

Try using this to cache the forward view $ionicConfigProvider.views.forwardCache(true);

这篇关于离子缓存不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆