I created an array of cards in php:
$card = array(
"id" => $row["id"],
"nome" => $row["nome"],
"indirizzo" => $row["indirizzo"],
"descrizione" => $row["descrizione"],
"prezzo" => $row["prezzo"],
"images" => array(),
"thumbs" => array(),
"dataInserimento" => $row["inserimento"],
"dataModifica" => $row["modifica"],
"bigImage" => array(),
"lat" => $row["lat"],
"lng" => $row["lng"],
"latInd"=>$row["latInd"],
"lngInd"=>$row["lngInd"]);
in a loop i do:
$cards["card"][] = $card;
and i pass the data to angular:
echo json_encode($cards);
In controller i copy the array into a scope variable:
$scope.cards=[];
CardService.getCards($scope.lastCard).then(function (success) {
CardService.setLocalCards(success.data.card);
/*check if all imges are loaded*/
for (var i = 0; i < success.data.card.length; i++) {
console.log(success.data.card);
console.log("numero di card caricate " + success.data.card[i].id);
var localCard = CardService.getLocalCard(success.data.card[i].id);
if (localCard === null || localCard.photosLoaded === true) {
$scope.cards.push((success.data.card[i]));
$scope.lastCard = success.data.card[i].id;
}
}
$ionicLoading.hide();
console.log("ultima scheda caricata " + $scope.lastCard);
}, function (fail) {
console.log("getCards error " + JSON.stringify(fail));
});
console.log($scope.cards);
the problem is if i try to access elements in $scope.cards i can access them from the then function in CardService but outside i get this:

