1

我想创建一个只对特定$resource调用采取行动的拦截器。我希望$resource调用本身指定是否应该拦截它们,而不是创建和维护一个大的白名单或黑名单供拦截器参考。

例如,使用$http你可以这样做:

$http.get('/things', { interceptMe: true } );

然后在拦截器中:

app.factory('anInterceptor', function() {
    return {
        'response': function (response) {
            if (response.config.interceptMe) {
                // take action...
            }
         }
    };
});

但是,$resource没有参数来指定这样的配置对象。我怎样才能做到这一点,$resource而不是$http

4

0 回答 0