我知道如何为视图清除缓存:
.state('app.list', {
cache : false,
url: "/lists/:listId",
views: {
'menuContent': {
templateUrl: "templates/listDashboard.html",
controller: 'listDashboardCtrl'
}
}
})
Run Code Online (Sandbox Code Playgroud)
,但我还需要其他东西 - 在控制器方法中删除应用程序的所有缓存.怎么做?
Kar*_*mar 13
我找到了一个解决方案,包裹clearCache和ClearHistory一个$timeout.像这样的东西.
$scope.logout = function(){
$location.path('/signin')
$timeout(function () {
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
$log.debug('clearing cache')
},300)
}
Run Code Online (Sandbox Code Playgroud)
编辑:更改超时秒数
您可以使用$ionicHistory。来自文档:
清除缓存()
删除每个 ionNavView 中的所有缓存视图。这既会从 DOM 中删除视图元素,也会破坏它的范围。
在你的listDashboardCtrl中写下:
function listDashboardCtrl($scope, $ionicHistory){
$ionicHistory.clearCache();
}
Run Code Online (Sandbox Code Playgroud)