码迷,mamicode.com
首页 > Web开发 > 详细

--@angularjs-- $location.path('/login')-$location服务用法示例

时间:2015-06-15 10:57:07      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

$httpProvider interceptor

.factory(‘auth403‘, [‘$rootScope‘, ‘$q‘, ‘$location‘, function auth403($rootScope, $q, $location) {

      return {
        request: function (config) {
          console.log(config);
          var start = new Date();
          return config;
        },
        response: function (result) {

          return result;
        },
        responseError: function (rejection) {
          console.warn(‘Failed with http‘, (rejection.message || rejection.status), ‘status‘);
          if (rejection.status == 403) {
            console.warn(‘Forbidden, need login to auth‘);
            $location.path(‘/login‘);
          }
          return $q.reject(rejection);
        }
      };
          }])

--@angularjs-- $location.path('/login')-$location服务用法示例

标签:

原文地址:http://www.cnblogs.com/koleyang/p/4576429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!