मैं अपने कोणीय नियंत्रक में http शीर्षलेखों तक पहुंचने का प्रयास कर रहा हूं लेकिन मुझे अपरिभाषित हो रहा है। इसके अलावा, मैं अपने कोणीय सेवा में हेडर प्रतिक्रिया देखने में सक्षम हूं जो मेरे नियंत्रक में प्रतिबिंबित नहीं कर रहा है। क्या कोई मुझे बता सकता है कि मुझे क्या याद आ रहा है? कृपया नीचे दिए गए कोड देखें:एंगुलरजेएस - http शीर्षलेखों तक पहुंच
सेवा:
cmApp.service('supplierService', function ($http, $q) {
this.getSuppliers = function (orderByColumn, skipRows, takeRows) {
var deferred = $q.defer();
$http({
method: 'GET',
url: 'api/supplier',
params: { orderBy: orderByColumn, skip: skipRows, take: takeRows },
timeout: 30000,
cache: false
}).
success(function (data, status, headers, config) {
// any required additional processing here
deferred.resolve(data, status, headers, config);
}).
error(function (data, status) {
deferred.reject(data, status, headers, config);
});
return deferred.promise;
}
नियंत्रक:
supplierService.getSuppliers($scope.orderby, $scope.skip, $scope.take)
.then(function (data, status, headers, config) {
**//getting undefined here.**
$scope.totalRecords = parseInt(headers('X-TotalRowCount'));
$scope.suppliers = data;
}, function (error) {
// error handling here
});
कृपया $ httpProvider देखें। अपने हेडर को नियंत्रित करने के लिए इसका इस्तेमाल करें। – kroonwijk