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
– Emir Marques
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
– Emir Marques
Is in the app configured
– César Sousa
And about the type returned, can verify if it is a text or json?
– Emir Marques
I’ll check how it’s coming
– César Sousa
It is coming in text format
– César Sousa
Do the following then. $Scope.ver_fotos_establishment = Eval(date);
– Emir Marques
I did it but it didn’t solve
– César Sousa
from a console.log( $Scope.ver_fotos_establishment = Eval(data)) see what appears in the browser console
– Emir Marques
Nothing appears on the console
– César Sousa
I already managed to resolve was a conflict with ng-controller
– César Sousa