0

Boa noite,

Estou a tentar buscar dados do php através do Angular.js mas não está a funcionar. Quando vou clicar na categoria não abre a próxima página onde serão mostrados os dados.

PHP

<?php
    header('Content-Type: application/json');

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

    $result = $conexao->prepare("SELECT * FROM colecoes WHERE menu = :menu AND activo = :activo ORDER BY pos ASC");
    $result->bindValue(':menu', 'Comer', PDO::PARAM_STR);
    $result->bindValue(':activo', 1, PDO::PARAM_INT);
    $result->execute();
    $rows = $result->fetchAll(PDO::FETCH_ASSOC);

    foreach ($rows as $row) {

        $result_anex = $conexao->prepare("SELECT * FROM colecoes_anexos WHERE id_mae = :row_id AND seccao = :seccao");
        $result_anex->bindParam(':row_id', $row['id'], PDO::PARAM_INT);
        $result_anex->bindValue(':seccao', 'thumbnail', PDO::PARAM_STR);
        $result_anex->execute();
        $row_anex = $result_anex->fetch(PDO::FETCH_ASSOC);

        echo json_encode($row);

    }
?>

Controlller

angular.module('starter.controllers', [])

.controller('comer_categorias', function($scope, $http) {
    $http.get("https://www.sabeonde.pt/api/api_categorias_comer.php").success(function (data) {
        $scope.comer = data;
    });
});

HTML

<ion-content ng-controller="comer_categorias">
    <h1 ng-repeat="comer_cat in comer">{{comer_cat.id}}</h1>
</ion-content>
1

1 Resposta 1

0

Qual é o erro?

tente fazer assim

$scope.comer = {};

$scope.GetData = function () {
$http.get("https://www.sabeonde.pt/api/api_categorias_comer.php").success(function (data) {

    $scope.comer = data;

}).error(function(data){
console.log(data);
})

}

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .