相关疑难解决方法(0)

在使用AngularJS的工厂中,$ location.path不会更改

我的工厂看起来像:

'use strict';

angular.module('myApp')
  .factory('httpInterceptor',['$q','$location', '$rootScope', function($q, $location, $rootScope){
    return {
      response: function(response) {

        if(response.success === false) {
console.log("Redirecting");
            $location.path('/login');
            return $q.reject(response);
        }

        return response || $q.when(response);
      }
    }
}]);
Run Code Online (Sandbox Code Playgroud)

它吐出日志,但不会改变路径.我该怎么做才能实现这一目标?

angularjs angularjs-routing angularjs-factory

5
推荐指数
2
解决办法
6336
查看次数