title: how can i access array elements in a $scope variable angular js from php?
body: <p>I created an array of cards in php:</p>
  
  <pre><code>$card = array(
        "id" =&gt; $row["id"],
        "nome" =&gt; $row["nome"],
        "indirizzo" =&gt; $row["indirizzo"],
        "descrizione" =&gt; $row["descrizione"],
        "prezzo" =&gt; $row["prezzo"],
        "images" =&gt; array(),
        "thumbs" =&gt; array(),
        "dataInserimento" =&gt; $row["inserimento"],
        "dataModifica" =&gt; $row["modifica"],
        "bigImage" =&gt; array(),
        "lat" =&gt; $row["lat"],
        "lng" =&gt; $row["lng"],
        "latInd"=&gt;$row["latInd"],
        "lngInd"=&gt;$row["lngInd"]);
  </code></pre>
  
  <p>in a loop i do:</p>
  
  <pre><code> $cards["card"][] = $card;
  </code></pre>
  
  <p>and i pass the data to angular:</p>
  
  <p>echo json_encode($cards);</p>
  
  <p>In controller i copy the array into a scope variable:</p>
  
  <pre><code>  $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 &lt; 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);
  </code></pre>
  
  <p>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:</p>
  
  <p><a href="https://i.stack.imgur.com/n773s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n773s.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/jC5Gc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jC5Gc.png" alt="enter image description here"></a>
  And i don't know how to access the elements</p>