[英]AngularJS + ion-list ng-repeat not Populating List
I am trying to populate an ion-list with ng-repeat from the database in Intel XDK using AngularJS and PHP. 我正在尝试使用AngularJS和PHP在英特尔XDK中使用ng-repeat填充离子列表。
I made some tries after reading some questions but nothing has worked. 我在阅读了一些问题后做了一些尝试,但没有任何效果。 It populates an empty list or nothing is displayed. 它会填充一个空列表,或者不显示任何内容。 What´s wrong with my code? 我的代码出了什么问题?
HTML: 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
<?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 更新 JSON
[{"ID":"0","TITLE":"Events of the Day","BODY":"Main Party at 22h!"}]
try to change 试着改变
$scope.items = response.data.records;
to 至
$scope.items = response.data;
Or show your JSON here 或者在这里显示您的JSON
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.