ionic 用户注销登录时,清空所有页面缓存
2016-05-06 17:40
375 查看
有人可能知道ionic的$ionicHistory是有一个清空缓存的命令的,命令如下:
clearHistory()
Clears out the app’s entire history, except for the current view.
但是此命令然并卵,所以我又看了一下API和源码发现了如下方法:
clearCache()
Removes all cached views within every ionNavView
. This both removes the view element from the DOM, and destroy it’s scope.
- Returns: promise
/** * @ngdoc method * @name $ionicHistory#clearCache * @return promise * @description Removes all cached views within every {@link ionic.directive:ionNavView}. * This both removes the view element from the DOM, and destroy it's scope. */ clearCache: function(stateIds) { return $timeout(function() { $ionicNavViewDelegate._instances.forEach(function(instance) { instance.clearCache(stateIds); }); }); },
API地址:http://ionicframework.com/docs/api/service/$ionicHistory/
源码地址:https://github.com/driftyco/ionic/blob/master/js/angular/service/history.js#L1
然后写了如下代码去清空页面缓存:
var views = $ionicHistory.viewHistory().views; var stateIds = []; for(var id in views){ stateIds.push(views[id].stateId); } $ionicHistory.clearCache(stateIds).then(function(){ $location.path('/login');//设置路由地址 })
转帖时请注明地址:http://346454763.iteye.comhttps://blog.csdn.net/blog/2296403
相关文章推荐
- 禁用页面缓存。目的:用户登录后退出。点击浏览器后退按钮造成的问题
- 过滤器(Filter)应用之------设置页面缓存、用户的自动登录和敏感词过滤
- asp.net清除页面缓存,防止页面回退重复提交数据及防止同一用户同时登录
- shiro登录验证(登录跳转到指定页面,验证码验证,不注销之前已登录用户下,再次登录)
- 禁用页面缓存。目的:用户登录后退出。点击浏览器后退按钮造成的问题
- javaweb用户注销后点击浏览器返回刷新页面重复登录问题的解决方法
- asp.net清除页面缓存,防止页面回退重复提交数据及防止同一用户同时登录
- asp.net清除页面缓存,防止页面回退重复提交数据及防止同一用户同时登录
- ionic1 跳转至某个页面之前判断用户是否登录
- 解决用户注销后点击浏览器返回刷新页面重复登录的问题
- 关系管理系统:显示所有用户jsp页面
- 简单的用户登录页面与后台数据库的交互
- hibernate登录过程中怎么传用户名(name)和密码(password)然后查到用户的ID并返回到页面上
- 普通用户注销windows server 2003 普通用户(users)远程登录立即自动注销的解决方法
- ASP.Net 2 入门(一)――用户登录和注销 【转】
- php 用户访问菜单页面,必须登录,判断用户是否登录
- 转:在ASP.NET 中实现单点登录(利用Cache, 将用户信息保存在服务器缓存中)
- ionic3 踩坑、如何全局监听所有页面事件(ionViewWillLeave),答案是ionic-angular 中的 App类。
- Django学习笔记4 用户注册和身份验证、登录、注销、注册