I'm attempting to append a JSON array to a JSON object. Here's my code:
$scope.packageElement = {
"settings": [
{
"showNextPallet": true,
"isParcelData": false,
"isFreightData": true,
"name": 0
}
]
};
dataFromServer = {
"pData": [
{
"PKUNIT": "LP",
"PKDESC": "LARGE PKG",
"PKDLEN": 30,
"PKDWDT": 20,
"PKDHTG": 20
}
]
};
$scope.packageElement.concat(dataFromServer.pData);
However, this is resulting in an error:
TypeError: undefined is not a function
at this line of code:
$scope.packageElement.concat(dataFromServer.pData);
This is the output I want to achieve:
var expectedOutPut = {
"settings": [
{
"showNextPallet": true,
"isParcelData": false,
"isFreightData": true,
"name": 0
}
], "pData": [
{
"PKUNIT": "LP",
"PKDESC": "LARGE PKG",
"PKDLEN": 30,
"PKDWDT": 20,
"PKDHTG": 20
}
]
};
Could someone please assist me in identifying where I am going wrong in my implementation?