我想创建一个只对特定$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
?