【发布时间】:2017-05-04 22:40:33
【问题描述】:
我有一个 Api,其中检索自定义标题:X-Total-Count:“项目总数”,我正在使用带有 ngResource 的角度。
我的工厂是这样的:
app.factory("shopFactory", function ($resource) {
return {
User: $resource("http://localhost:58495/users/api/User/?id=:id", { id: "@id" }),
Category: $resource("http://localhost:58495/category/:id", { id: "@id" }),
Product: $resource("http://localhost:58495/products/?from=:from&to=:to", { from: "@from", to: "@to" })
};
});
当我调用它时:
var productServer = shopFactory.Product.query({ from: 0, to: 10 }).$promise.then(function (response) {
$scope.product = response;
console.log(response);
}, function (error) {
console.log("ERROR");
console.log(error);
});
如何通过 ngResource 访问我的自定义标头,我可以访问它,但是使用 $http,我想使用 $resource 方式,谢谢
【问题讨论】:
标签: angularjs http-headers ngresource