I am trying to put the contents of an array into another. I have this json ($scopeProducts)...
{
"ID": "...",
"Groups": [
{
"Products": []
}
{
"Other": []
}
]
}
And I am trying to add the following json into the 'Products' array ($scope.selectedProducts)...
[
{
"ProductCode": "Code1",
},
{
"ProductCode": "Code1",
},
]
and I end up getting this...
{
"ID": "...",
"Groups": [
{
"Products":
[
[
{
"ProductCode": "Code1",
},
{
"ProductCode": "Code1",
},
]
]
}
{
"Other": []
}
]
}
... which is wrong (check the double [[ in the products array). I am using the javascript push function...
$scopeProducts.Groups[0].Products.push($scope.selectedProducts);
Could anyone tell me how to do this correctly without creating the double array [[]] ? Many thanks