【发布时间】:2016-07-26 17:52:24
【问题描述】:
我正在使用 Ionic 开发应用程序,但缓存未按预期工作。
每次我从root.home.notifs 切换到root.home.chats 时,chats 视图都会刷新(其控制器会重新初始化)。
我有 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>
这些状态(我的控制器是空的):
.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)
注意:我注意到此错误取决于我首先导航到的状态。有一个身份验证系统调用$state.$go('root.home.notifs')。更改此项会更改正确缓存的视图
关于如何解决这个问题的任何提示?
【问题讨论】: