user2882684 user2882684 - 6 months ago 18
AngularJS Question

push json get request items into an array

I'm trying to push json objects into an array with angular. I'm getting an error 'Cannot read property 'push' of undefined'. Is there another way to do this with angular?

$.each(data.Document.Placemark, function(index, item) {
var locations = [];
$scope.locations.push( + ", " + item.Point.coordinates);


If you want locations to be a property of $scope then you have to make it a property of $scope instead of a local variable.

$scope.locations = [];