AngularJS $http响应头

前端之家收集整理的这篇文章主要介绍了AngularJS $http响应头前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这个简单的问题是让我烦恼我在Web Api Rest服务器的响应头中有一个自定义值。
我可以看到它Firebug为:
X-TotalPages 204
我试图把它放在我的AngularJS控制器中。代码如下。
但是我没有找到任何好的例子来做到这一点。
console.log(headers()[‘X-TotalPages’]);原木’未定义’
var assets = angular.module("Assets",['ui.bootstrap']);
assets.controller('AssetSearchController',function ($scope,$http) {
    $scope.test = 'very';
    $scope.getItems = function () {
        $http({ method: 'GET',url: 'http://localhost:57772/api/assets',params: { search: 1,page: 0,pageSize: 10 } }
            ).success(function (data,status,headers,config) {
                $scope.currentPage = 4;                
                console.log(headers()['X-TotalPages']);

            $scope.items = data;
        }).
        error(function (data,status) {
            console.log(JSON.stringify(data));
            console.log(JSON.stringify(status));
        });

    };
你应该使用:header(‘X-TotalPages’)

(发布Wawy的答案,所以问题可以解决。)

原文链接:https://www.f2er.com/angularjs/145029.html

猜你在找的Angularjs相关文章