I am trying my best to program an angular app. I have a problem pushing an empty array into an object.
I get an error:
TypeError: Cannot read property 'push' of undefined
I have an object called items which looks like this:
Object
{
"Name": "name",
"Description": "description"
}
I would like to push an empty array into the object that can contain another array. Something like this.
Object
{
"Name": "name",
"Description": "description",
"Related Items": {
Item1:{...},
Item2:{...},
...
}
}
My controller does this when it is called:
$scope.push = function () {
$scope.item.push({"Related Items":[]});
};
I know I must be getting mixed up with something simple about the JSON Objects and Arrays, but I can't seem to find a solution.
Thankyou!