我试图设置嵌套的ng-repeat,但却无法弄清楚错误是什么。在嵌套的ng-repeat
中没有打印任何内容HTML:
<div ng-repeat="person in persons">
<p> {{ person.name }} </p>
<div ng-repeat="friend in person.mutual_friends">
{{ friend.name }}
</div>
</div>
JSON:
$scope.persons = [
{
name: 'First Person',
mutual_friends: [
{
name: 'Mutual Friend 1'
},
{
name: 'Mutual Friend 2'
},
]
},
{
name: 'Second Person',
mutual_friends: [
{
name: 'Mutual Friend 1'
},
{
name: 'Mutual Friend 2'
},
]
},
]
答案 0 :(得分:0)
JSON就是问题所在。
以下JSFiddle代码有效:
https://jsfiddle.net/sushruthreddygade/hcpb229g/2/
JSON结构:
[
{
"name": "First Person",
"mutual_friends": [
{
"name": "Mutual Friend 1"
},
{
"name": "Mutual Friend 2"
}
]
},
{
"name": "Second Person",
"mutual_friends": [
{
"name": "Mutual Friend 3"
},
{
"name": "Mutual Friend 4"
}
]
}