相关疑难解决方法(0)

AngularJS的全局Ajax错误处理程序

当我的网站是100%jQuery时,我曾经这样做过:

$.ajaxSetup({
    global: true,
    error: function(xhr, status, err) {
        if (xhr.status == 401) {
           window.location = "./index.html";
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

为401错误设置全局处理程序.现在,我使用angularjs $resource$http我的(REST)请求到服务器.有没有办法类似地设置角度的全局错误处理程序?

javascript ajax angularjs

82
推荐指数
3
解决办法
7万
查看次数

标签 统计

ajax ×1

angularjs ×1

javascript ×1