이 간단한 문제는 나를 괴롭 히고 있습니다. 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));
});
};
다음을 사용해야합니다. headers('X-TotalPages')
(질문이 해결 될 수 있도록 Wawy의 답변을 게시합니다.)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다