0
我正在開發一個應用程序。我有多個Ajax調用,我需要綁定所有json到單個json中。我使用下面的代碼。但是,當它做的時候還附加了json響應頭,狀態和其他。我只需要推送關鍵值。任何人都可以幫我解決這個問題嗎?
我的代碼如下:
$scope.downloadPdf = function() {
var frequency = $http.get("myapplicationurl" + $stateParams.searchId + "?" + "startDate=" + $stateParams.startDate + "&" + "endDate=" + $stateParams.endDate)//,
// name = $http.get("../myapplicationurl/" + $stateParams.searchId)
$q.all([frequency]).then(function (arrayOfResults) {
angular.forEach(arrayOfResults[0], function (value, key) {
angular.forEach(value[0], function (data, header) {
$scope.header.push([header]);
})
angular.forEach(value, function (it, header) {
$scope.columns.push(it);
console.log("Body : " + $scope.columns);
})
})
console.log("Header : " + $scope.header);
pdfMake.createPdf({
header: 'simple text',
content: [
{
text: 'Fruits and Calories'
},
{
style: 'demoTable',
table: {
widths: ['*', '*', '*'],
body: [
$scope.header,
// $scope.columns
]
}
}
],
footer: {
columns: [
'Left part',
{text: 'Right part', alignment: 'right'}
]
},
styles: {
header: {
bold: true,
color: '#000',
fontSize: 11
},
demoTable: {
color: '#666',
fontSize: 10
}
}
}).download('Sample.pdf');
});
};