我知道这会在特定的状态或视图中伪造缓存。
禁用状态提供程序中的缓存
$stateProvider.state('myState', {
cache: false,
url : '/myUrl',
templateUrl : 'my-template.html'
})禁用带有属性的缓存
<ion-view cache-view="false" view-title="My Title!">
...
</ion-view>但是,我需要从特定的视图转换(例如)错误缓存。
$state.go('home',{cache: false}); 在这里,我不得不伪造本地状态缓存,我尝试了这个,但还没有工作。
发布于 2015-05-28 06:12:07
第一次使用模板时,会将其加载到模板缓存中,以便快速检索。您可以直接使用$templateCache服务在缓存中添加模板或将其从缓存中删除。试试下面的例子
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined'){
$templateCache.remove(current.templateUrl);
}
//Or if you want to remove next state from cache
if (typeof(next) !== 'undefined'){
$templateCache.remove(next.templateUrl);
}
.....
});
}https://stackoverflow.com/questions/30498268
复制相似问题