所以我有这个数组,其中包含有关父页面和子页面的信息。即时尝试使用ng-repeat打印出来但我似乎只获得了第一级数据。我似乎无法访问内部子数据。感谢任何帮助
这是迄今为止我尝试过的
<div ng-repeat="page in pages" >{{page.post_title}}
<div ng-repeat="child in page.children">{{child.post_title}}</div>
</div>
$scope.pages=[
{
"id": "1",
"post_title": "Batman Ipsum",
"publish_date": "Monday, October 12th 2015, 9:35:16 pm",
"is_draft": "0",
"children": [
{
"id": "7",
"post_title": "TV Ipsum",
"publish_date": "Monday, October 12th 2015, 11:44:24 pm",
"is_draft": "0",
"children": [
{
"id": "6",
"post_title": "Yet another Batman Ipsum",
"publish_date": "Thursday, October 22nd 2015, 11:00:00 pm",
"is_draft": "0"
}
]
}
]
},
{
"id": "2",
"post_title": "Title fit for a (precariously enthroned) king",
"publish_date": "Monday, October 12th 2015, 10:07:01 pm",
"is_draft": "0"
},
{
"id": "3",
"post_title": "Cupcake Ipsum",
"publish_date": "Monday, October 12th 2015, 10:13:23 pm",
"is_draft": "0"
},
{
"id": "4",
"post_title": "The most presidential lorem ipsum in history.",
"publish_date": "Monday, October 12th 2015, 10:27:15 pm",
"is_draft": "0"
},
{
"id": "5",
"post_title": "Quote Ipsum",
"publish_date": "Null",
"is_draft": "1"
}
]
但我得到的结果是
Batman Ipsum
TV Ipsum
Title fit for a (precariously enthroned) king
Cupcake Ipsum
The most presidential lorem ipsum in history.
Quote Ipsum
没有孩子被打印
答案 0 :(得分:0)
您还需要一个<div ng-repeat="item in child.children"></div>
来访问孩子父母的孩子!
如果您的上一个孩子总是一个孩子,您可以
访问它们child[0].id