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

$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);
        }
      };
          }])
原文地址:https://www.cnblogs.com/koleyang/p/4576429.html