Trying to push in new nested objects. Keep getting cannot read property push of undefined
on line 3.
Why isn't this working? Should I be doing this another way?
$scope.item.deliverables[0].steps[0].versions = [];
$scope.item.deliverables[0].steps[0].versions.push({assets:[{url:'aaa'}]})
$scope.item.deliverables[0].steps[0].versions.assets.push({url:'bbb'})
You need to access
versions
itself as an array like this:Since you did this:
versions
is an array andassets
as a property to that array isundefined
. Hence, the error