我在 html 中显示 JSON 元素时遇到问题
这是JSON
peopleList: [
{
name: 'John',
address: 'Street A, 143',
sons: [{
First: "Jack",
Second: "Jane",
Third: "Maria"
}]
}]
这是html
<div ng-repeat="people in peopleList">
<span class="">name: {{people.name}}</span><br>
<span class="">sons: {{people.sons}}</span>
</div>
这个节目儿子们:[{"First": "Jack", "Second": "Jane", "Third": "Maria", "_id": "5604e8e474758451s6d813"}]
我试过用
people.sons.First
但什么也没显示
最佳答案
我觉得你的 ng-repeat 迭代有点可疑,试试下面
<div ng-repeat="name in names">
<span class="">name: {{name.name}}</span><br>
<span class="">sons: {{name.sons.First}}</span>
</div>
如果你想迭代 Sons 那么它可能如下所示
<div ng-repeat="name in names">
<span class="">name: {{name.name}}</span><br>
<span class="" ng-repeat="son in name.sons">
sons First: {{son.First}}
sons Second: {{son.Second}}
sons Third: {{son.Third}}
</span>
</div>
关于javascript - 如何在 Angular 上显示 json 列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32776317/