Create:
I am using $scope.services
where I am storing my list of services. This is an array of objects:
$scope.services = [{
title : undefined,
quantity : undefined,
pricePerUnit : undefined,
priceCalculated : undefined,
order : undefined
}];
I can then push another object into array.
$scope.services.push({
title : undefined,
quantity : undefined,
pricePerUnit : undefined,
priceCalculated : undefined,
order : undefined
});
So far, so good. I am then using this object as a model within Angular, to show its content.
Update:
I am calling API and getting my JSON in format:
{
someData: "some data",
services: {
0: {
id: 101,
offer_id: 101,
title: "some title",
...
},
1: {
...
}
}
}
Appending received data by $scope.services = data.services
and then when I am calling $scope.services.push
I get the console error
TypeError: $scope.services.push is not a function.
What could be wrong? Is it the JSON/array issue? I never got to the bottom of this, so any theory knowledge would be appreciated as well. Thank you in advance.