$http Get Ionic et tutoriel

Par wowoteur, il y a 10 ans


Bonsoir,
Je veux récupérer un fichier json avec $http GET pour ensuite faire un ng-repeat.
Le problème est que j'ai beau regarder sur le net, ça ne marche pas...
Voici le format de mon json:
[{"ID":"1","NOM":"LIMONEST","IPDEB":"010.084.001.001","IPFIN":"010.084.001.254"},{"ID":"2","NOM":"RILLIEUX","IPDEB":"010.088.001.001","IPFIN":"010.088.001.254"}]

Je le récupére avec ça :

app.controller('customersController', ['$scope', '$http', function ($scope, $http) { $http.get("http://demo-****.ovh/JSON/sites.php") .success(function (response) { $scope.sites = response; }); }]);

et je voulais faire cela dans ma page :

<div ng-controller="customersController"> <ion-list> <ion-item ng-repeat="x in sites"> {{ x.NOM + ', ' + x.IPDEB}} </ion-item> </ion-list> </div>

Dans ma page php j'ai mis :

<?php header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); // set up the connection variables $db_name = 'SITE'; $hostname = 'localhost'; $username = $password = // connect to the database $dbh = new PDO("mysql:host=$hostname;dbname=$db_name", $username, $password); // a query get all the records from the users table $sql = 'SELECT * FROM SITES'; // use prepared statements, even if not strictly required is good practice $stmt = $dbh->prepare( $sql ); // execute the query $stmt->execute(); // fetch the results into an array $result = $stmt->fetchAll( PDO::FETCH_ASSOC ); // convert to json $json = json_encode( $result ); // echo the json string echo $json; ?>

Mais ça ne veut pas.
Vous n'avez pas un bon tutoriels où je pourrai comprendre où cela merde .
Merci de votre aide.

Aucune réponse