我从http restful
返回了这个json对象[
{
"person": {
"id": 1,
"fullName": "A person # 1",
"age": 7
}
},
{
"person": {
"id": 2,
"fullName": "A person # 2",
"age": 22
}
},
{
"person": {
"id": 3,
"fullName": "A person # 3",
"age": 34
}
},
{
"person": {
"id": 4,
"fullName": "A person # 4",
"age": 25
}
},
{
"person": {
"id": 5,
"fullName": "A person # 5",
"age": 17
}
},
{
"person": {
"id": 6,
"fullName": "A person # 6",
"age": 4
}
},
{
"person": {
"id": 7,
"fullName": "A person # 7",
"age": 30
}
},
{
"person": {
"id": 8,
"fullName": "A person # 8",
"age": 7
}
},
{
"person": {
"id": 9,
"fullName": "A person # 9",
"age": 36
}
},
{
"person": {
"id": 10,
"fullName": "A person # 10",
"age": 35
}
}
]
这是我的little angularJS代码:
<div class="container">
<div class="jumbotron text-center">
<h1>Person List</h1>
<ul>
<li ng-repeat="person in persons">{{person.fullName}} is {{person.age}} years old</li>
</ul>
</div>
</div>
正如你所看到的,我是在做人。现在......“人员”是从控制器中的$ http.get中检索到的整个json对象。 此外,由于它是一系列人物,为什么不为“人在人”工作?然后person.fullName和person.age应该工作:(
有什么想法吗?
谢谢!
答案 0 :(得分:4)
您的对象实际上嵌套在每个资源中person
,所以您想要的是{{person.person.fullName}}
和{{person.person.age}}
。