Here is the structure of my array:
"taxDetails": [
{
"taxType": "Flat Service Charge",
"taxAmount": 0
},
{
"taxTypeId": "1",
"taxType": "Service Tax",
"validFrm": "2016-01-18",
"validTo": "2020-02-27",
"taxPrctgSbt": 200,
"taxPrctg": 14.5,
"taxAmount": 300,
"remarks": "test"
},
{
"taxTypeId": "2",
"taxType": "VAT",
"validFrm": "2016-01-18",
"validTo": "2020-02-29",
"taxPrctgSbt": 300,
"taxPrctg": 12.5,
"taxAmount": 400,
"remarks": "rest"
},
{
"taxTypeId": "3",
"taxType": "Swatch Bharath Cess",
"validFrm": "2016-01-18",
"validTo": "2020-03-31",
"taxPrctgSbt": 400,
"taxPrctg": 1,
"taxAmount": 500,
"remarks": "fest"
},
{
"taxTypeId": "5",
"taxType": "Swatch Bharath Cess",
"validFrm": "2016-01-18",
"validTo": "2020-03-31",
"taxPrctgSbt": 400,
"taxPrctg": 1,
"taxAmount": 500,
"remarks": "fest"
},
{
"taxTypeId": "6",
"taxType": "Percent Service Char",
"validFrm": "2016-01-18",
"validTo": "2020-08-01",
"taxPrctgSbt": 200,
"taxPrctg": 10,
"taxAmount": 200,
"remarks": "zest"
},
{
"taxTypeId": "7",
"taxType": "Percent Service Char",
"validFrm": "2016-01-18",
"validTo": "2020-08-01",
"taxPrctgSbt": 300,
"taxPrctg": 15,
"taxAmount": 200,
"remarks": "zest"
}
]
Below is the code snippet:
$scope.paymentForm.taxDetails = [];
//$scope.taxDetails = [];
var flat= {"flat" : true};
$scope.taxList = function () {
$http.get('http://192.168.0.113:8080/feasthunt/registration/getTaxDetails?restUniqCode='+uniqueCode)
.success(function (response) {
$scope.paymentForm.taxDetails = response;
for(var i=0; i< $scope.paymentForm.taxDetails.length; i++){
$scope.paymentForm.taxDetails[i].push( flat );
}
})
.error(function (data, status, header, config) {
//alert('error');
});
};
$scope.taxList();
The goal is to add another object in every element array to achieve this final format:
"taxDetails": [
{
"taxType": "Flat Service Charge",
"taxAmount": 0,
"flat": true
},
{
"taxTypeId": "1",
"taxType": "Service Tax",
"validFrm": "2016-01-18",
"validTo": "2020-02-27",
"taxPrctgSbt": 200,
"taxPrctg": 14.5,
"taxAmount": 300,
"remarks": "test",
"flat": true
},
{
"taxTypeId": "2",
"taxType": "VAT",
"validFrm": "2016-01-18",
"validTo": "2020-02-29",
"taxPrctgSbt": 300,
"taxPrctg": 12.5,
"taxAmount": 400,
"remarks": "rest",
"flat": true
},
{
"taxTypeId": "3",
"taxType": "Swatch Bharath Cess",
"validFrm": "2016-01-18",
"validTo": "2020-03-31",
"taxPrctgSbt": 400,
"taxPrctg": 1,
"taxAmount": 500,
"remarks": "fest",
"flat": true
},
{
"taxTypeId": "5",
"taxType": "Swatch Bharath Cess",
"validFrm": "2016-01-18",
"validTo": "2020-03-31",
"taxPrctgSbt": 400,
"taxPrctg": 1,
"taxAmount": 500,
"remarks": "fest",
"flat": true
},
{
"taxTypeId": "6",
"taxType": "Percent Service Char",
"validFrm": "2016-01-18",
"validTo": "2020-08-01",
"taxPrctgSbt": 200,
"taxPrctg": 10,
"taxAmount": 200,
"remarks": "zest",
"flat": true
},
{
"taxTypeId": "7",
"taxType": "Percent Service Char",
"validFrm": "2016-01-18",
"validTo": "2020-08-01",
"taxPrctgSbt": 300,
"taxPrctg": 15,
"taxAmount": 200,
"remarks": "zest",
"flat": true
}
]