如果没有调用ajax angularjs,则重定向到登录页面

时间:2015-04-15 14:59:23

标签: ajax angularjs

在我的script.js中,如果没有ajax调用,我必须重定向到登录页面,但我有response.status = 200!

myapp.factory('myHttpResponseInterceptor',['$q','$location',function($q,$location){

        return {
            response: function(response) {
                return response;
            }, responseError: function(response) {
                if (response.status === 401)
                    $location.url('/login');
                return $q.reject(response);
            }
        }

    }]);

    myapp.config(['$httpProvider',function($httpProvider) {
        $httpProvider.interceptors.push('myHttpResponseInterceptor');
    }]);

0 个答案:

没有答案