angular 路由拦截
来源:互联网 发布:csp软件商业绘画 编辑:程序博客网 时间:2024/06/01 08:19
$scope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){ if(toState.name=='login') return; if(!comApi.isNotNullAndUndefined($sessionStorage.ustu)){ event.preventDefault();// 取消默认跳转行为 $state.go("login",{from:toState.name,w:'notLogin'});//跳转到登录界面 } });//登录控制器 var from = $stateParams.from; console.log($stateParams); $state.go(from && from != "login" ? from : "app.home");/** * Created by wanggs *///拦截http请求的拦截器app.factory('factoryFilters', function ($sessionStorage, $location) { var sessionInjector = { request: function (config) { //请求之前 //判断是否登陆.登陆后将token放到请求头部 if ($sessionStorage.ustu) { config.headers["hahh"] = $sessionStorage.ustu; } return config; }, response: function (config, header, header1, header2) { //请求成功之后 //从返回头部获跳转 if (config.headers("hahh")) { $sessionStorage.ustu = config.headers("hahh"); } return config; }, requestError: function (config) { //请求之前错误 return config; }, responseError: function (config) { //请求之后错误 return config; } }; return sessionInjector;});app.config(['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push('factoryFilters');}]);
0 0
- angular 路由拦截
- angular 未登录状态拦截路由跳转
- angular 路由
- angular路由
- Angular路由
- angular 路由
- Angular路由
- angular路由
- angular路由
- angular路由
- Angular路由
- angular路由
- angular 路由
- Angular路由
- Angular 路由
- Angular路由
- angular 路由
- angular路由
- 设计模式
- shiro登录验证
- 简单的,到处是bug的,菜鸟自学初学写的,Java的银行存取款代码
- MySQL必知必会之2
- apk支付宝支付流程
- angular 路由拦截
- HTML5与原生开发孰优孰劣?这场战争是时候结束了
- 每天一点Linux命令
- vue.js实现用户评论、登录、注册、及修改用户部分信息功能代码。
- jsp跳转servlet以后转发或重定向以后css和js样式消失。页面布局混乱
- ListView图片错乱原因分析
- CodeForces 731 C.Socks(贪心+并查集)
- C++TinyXml读取解析xml文件
- ElasticSearch--以属性为中心的查询