AngularJS + ion-list ng-repeat not Population List

I am trying to populate an ng-repeat ion list from a database in Intel XDK using AngularJS and PHP.

I made several attempts after reading some questions, but nothing worked. It fills an empty list or nothing is displayed. What is wrong with my code?

HTML:

<ion-view title="Temporada 2016" id="page1" style="background-color:#FFFFFF;">
<ion-content padding="true" class="has-header">
    <div id="temporada2016-button-bar1" class="button-bar">
        <button id="temporada2016-button2" style="color:#008BBB;" class="button button-light  button-block button-outline active-bymyself">Notícias</button>
        <a ui-sref="menu.fotos" id="temporada2016-button3" style="color:#008BBB;" class="button button-light  button-block button-outline">Fotos</a>
    </div>
    <form id="temporada2016-form8" class="list">
        <label class="item item-input" name="search_news">
            <i class="icon ion-search placeholder-icon"></i>
            <input type="search" placeholder="Pesquisar Notícia">
        </label>
    </form>
    <!--<div class="item item-body list-container" id="temporada2016-list-item-container4">
        <div id="temporada2016-markdown7" style="margin-top:0px;color:#666666;">
            <p>{{title}}</p>
        </div>
    </div> -->
    <ion-list class="widget uib_w_1 d-margins" data-uib="ionic/list" data-ver="0">
        <ion-item class="item widget uib_w_2" data-uib="ionic/list_item" data-ver="0" ng-repeat="x in items">{{ x.TITLE }}</ion-item>
    </ion-list>
</ion-content>
</ion-view>

Angular:

.controller('temporada2016Ctrl', ['$scope', '$http', function ($scope, $http) {

$http.get("http://localhost/select-news.php").then(function(response){

    console.log(response);
    console.log(JSON.stringify(response));

    $scope.items = response.data.records;

});

}])

Php

<?php 

include_once('conn.php');

$sql = $mysqli->query("SELECT * FROM news");

    if($sql->num_rows > 0){
        while($row = $sql->fetch_array(MYSQLI_BOTH)){
            $registro = array(
                "ID" => $row['id'],
                "TITLE" => $row['title'],
                "BODY" => $row['body']
                );

        $retorno[] = $registro;

        }   
    }

    $mysqli->close();
    $retorno = json_encode($retorno);
    echo $retorno;

?>

UPDATE JSON

[{"ID":"0","TITLE":"Events of the Day","BODY":"Main Party at 22h!"}] 
+4
source share
1 answer

try to change

$scope.items = response.data.records;

to

$scope.items = response.data;

Or show your JSON here

+2
source

Source: https://habr.com/ru/post/1653496/


All Articles