Why does ng-repeat not work in php json?

Asked

Viewed 78 times

0

I have a mobile app where I make a ng-repeat to list a photo gallery that well through a JSON php what happens and that I think I have all right but does not list me any image I have tried to query sql directly into sql and gives me no error list as well.

Controller

.controller('VerFotosEstabelecimento', function($scope, $http, $stateParams) {
    $http.get("https://www.sabeonde.pt/api/api_ver_fotos_estabelecimento.php?slug="+$stateParams.EstabelecimentoSlug).success(function (data) {
        $scope.ver_fotos_estabelecimento = data;
    });
})

HTML where list photos

<div class="card">
        <div class="item item-text-wrap">
            <h2 style="margin:0px 0px 10px 0px;">Fotos</h2>
            <div class="row">
                <div class="col" ng-repeat="fotos in ver_fotos_estabelecimento"> 
                    <img ng-src="https://www.sabeonde.pt/gtm/anexos/fotos/{{fotos.id_anexo}}.{{fotos.tipo}}" />
                </div>
            </div>  
            <div style="float: left;" ng-click="fotos()" ng-controller="ModalFotos" class="caixa_limite">+'.$fotos_maior_valida.'</div>
            <div style="float: left; margin:0px 0px 20px 5px;" class="caixa_limite"><i style="font-size: xx-large;" class="ion-camera"></i></div>  
        </div>
</div>   

PHP

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Content-type: application/json");

require_once("../funcoes/funcoes.php");


$result = $conexao->prepare("SELECT * FROM estabelecimentos
                            INNER JOIN estabelecimentos_anexos ON estabelecimentos_anexos.id_mae = estabelecimentos.id
                            WHERE estabelecimentos.slug = :slug  AND estabelecimentos_anexos.seccao = :seccao LIMIT 9");

$result->bindValue(':slug', $_GET['slug'], PDO::PARAM_STR);
$result->bindValue(':seccao', 'fotos', PDO::PARAM_STR);
$result->execute();
$rows = $result->fetchAll(PDO::FETCH_ASSOC);

echo json_encode($rows);    
  • Take a look at the format your json is coming from. It may be that json is in text format. That’s why it doesn’t have the expected behavior. In that case you will have to give an Eval when you receive the values of the ajax call

  • Another thing, in your source I didn’t see the controller setting in HTML or App. I believe they may be in the code higher up. But I ask only to confirm

  • Is in the app configured

  • And about the type returned, can verify if it is a text or json?

  • I’ll check how it’s coming

  • It is coming in text format

  • Do the following then. $Scope.ver_fotos_establishment = Eval(date);

  • I did it but it didn’t solve

  • from a console.log( $Scope.ver_fotos_establishment = Eval(data)) see what appears in the browser console

  • Nothing appears on the console

  • I already managed to resolve was a conflict with ng-controller

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.