I am trying to push values from one array to a second array, but every time I output the second array, I am getting an empty '[]' output
$scope.myArray = [];
$http.get("http://127.0.0.1/dbtest/init.php").then(function(response){
$scope.myData = response.data.records;
for(var i = 0; i < $scope.myData.length; i++){
$scope.myArray.push({
text: $scope.myData[i].id,
image: $scope.myData[i].url
});
}
console.log($scope.myData); //1st output this one works
});
console.log($scope.myArray); //2nd output shows empty array
This is the result I get from the http request