[英]IONIC JSON Issue
我正在尝试在主页中列出所有书籍的标题,图片和作者。 但是我在主页上什么都看不到。 确实需要有人帮助。 我仍在学习如何使用来自JSON的数据。
请参阅我的codepen http://codepen.io/ccrash/pen/rLAVXG
home.html
<ion-view view-title="Dashboard">
<ion-content class="padding">
<h2>Ionic GET Json Example</h2>
<ion-item ng-repeat="x in books">
<div> {{x.data.items.title}} </div>
<div> {{x.data.items.image[0]}} </div>
<div> {{x.data.items.author}} </div>
</ion-item>
</ion-content>
</ion-view>
App.js
.controller('HomeCtrl', function($http, $scope, $ionicSideMenuDelegate) {
$scope.books = [
{
"status": "OK",
"data": {
"category": "book",
"language": "en",
"items": [
{
"category": "book",
"language": "en",
"title": "book 1",
"image": [
"https://pbs.twimg.com/profile_images/739247958340698114/fVKY9fOv.jpg"
],
"author": "Mr X",
"snippeted": "This is the snippets",
"summary": "Summary1",
"pub_datetime": "2016-08-18 18:56:00",
"link": "/news/1",
"sid": 1,
"mod_datetime": "2016-08-18 19:05:55",
"freecontent": "yes"
},
{
"category": "book",
"language": "en",
"title": "book 2",
"image": [
"http://www.vodafone.co.nz/cms/images/credit-card.jpg"
],
"author": "Mr Y",
"snippeted": "Snippet 2",
"summary": "Summary 2",
"pub_datetime": "2016-08-18 18:53:00",
"link": "/news/352837",
"sid": 2,
"mod_datetime": "2016-08-18 19:07:59",
"freecontent": "yes"
},
{
"category": "book",
"language": "en",
"title": "book 3",
"image": [
"https://i.ytimg.com/vi/LNuFe2HV8Bs/maxresdefault.jpg"
],
"author": "Mr Z",
"snippeted": "Snippet 3",
"summary": "Summary 3",
"pub_datetime": "2016-08-18 18:51:00",
"link": "/book/352835",
"sid": 3,
"mod_datetime": "2016-08-18 18:55:32",
"freecontent": "yes"
}
],
"next_cursor": "75a",
"next_url": "/c/en/book/75a?alt=json",
"mod_datetime": "2016-08-18 19:26:36"
}
}
];
})
也许您应该了解有关json的更多信息。
您应该ng-repeat="x in books[0].data.items"
使用ng-repeat="x in books[0].data.items"
来获取图书清单中的每一本书,然后您就可以获取像这样的图像标题{{x.title}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.