user2882684 user2882684 - 1 year ago 81
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);

Answer Source

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 = [];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download