我有一些JSON数据,我将其加载到一个列表中,该列表在所述数据中包含子列表。使用get调用从API中提取JSON数据
"pet": [
{
"options": {
"option": [
{
"$t": "hasShots"
},
{
"$t": "altered"
},
{
"$t": "housetrained"
}
]
},
"status": {
"$t": "A"
},
"contact": {
"phone": {
"$t": "emails only please"
},
"state": {
"$t": "NC"
},
"address2": {
},
"email": {
"$t": "techmed1@netzero.net"
},
"city": {
"$t": "Charlotte"
},
"zip": {
"$t": "28226"
},
"fax": {
},
"address1": {
}
},
"age": {
"$t": "Senior"
},
"size": {
"$t": "M"
},
"media": {
"photos": {
"photo": [
{
"@size": "pnt",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/1\/?bust=1475677088&width=60&-pnt.jpg",
"@id": "1"
},
{
"@size": "fpm",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/1\/?bust=1475677088&width=95&-fpm.jpg",
"@id": "1"
},
{
"@size": "x",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/1\/?bust=1475677088&width=500&-x.jpg",
"@id": "1"
},
{
"@size": "pn",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/1\/?bust=1475677088&width=300&-pn.jpg",
"@id": "1"
},
{
"@size": "t",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/1\/?bust=1475677088&width=50&-t.jpg",
"@id": "1"
},
{
"@size": "pnt",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/2\/?bust=1475677088&width=60&-pnt.jpg",
"@id": "2"
},
{
"@size": "fpm",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/2\/?bust=1475677088&width=95&-fpm.jpg",
"@id": "2"
},
{
"@size": "x",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/2\/?bust=1475677088&width=500&-x.jpg",
"@id": "2"
},
{
"@size": "pn",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/2\/?bust=1475677088&width=300&-pn.jpg",
"@id": "2"
},
{
"@size": "t",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/2\/?bust=1475677088&width=50&-t.jpg",
"@id": "2"
},
{
"@size": "pnt",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/3\/?bust=1475677088&width=60&-pnt.jpg",
"@id": "3"
},
{
"@size": "fpm",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/3\/?bust=1475677088&width=95&-fpm.jpg",
"@id": "3"
},
{
"@size": "x",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/3\/?bust=1475677088&width=500&-x.jpg",
"@id": "3"
},
{
"@size": "pn",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/3\/?bust=1475677088&width=300&-pn.jpg",
"@id": "3"
},
{
"@size": "t",
"$t": "http:\/\/photos.petfinder.com\/photos\/pets\/36298811\/3\/?bust=1475677088&width=50&-t.jpg",
"@id": "3"
}
]
}
},
"id": {
"$t": "36298811"
},
"shelterPetId": {
"$t": "Domino"
},
"breeds": {
"breed": {
"$t": "Domestic Medium Hair"
}
},
"name": {
"$t": "Domino"
},
"sex": {
"$t": "M"
},
"description": {
"$t": "Domino is a sweet, talkative kitty with lots of purr-sonality. He never meets a stranger, and will let children carry him around in their arms. \nHe has tested positive for FIV, but we have had him in our rescue since 2009, and he has never had any health problems at all. He is neutered and up to date on vaccinations.We think he was born around 2005-2006. Must be an indoor only cat. He has had regular dental cleanings; last one was April of 2015. He would make a great companion for anyone who wants an affectionate kitty to love and care for."
},
"mix": {
"$t": "no"
},
"shelterId": {
"$t": "NC773"
},
"lastUpdate": {
"$t": "2017-03-15T12:37:11Z"
},
"animal": {
"$t": "Cat"
}
}
]

我的代码是
<ol><li ng-repeat="pet in pets | orderBy: 'name.$t'">
<div>{{pet.name.$t}} - {{pet.animal.$t}}</div>
<div ng-repeat="pic in pet.photo">{{pic.$t}}</div>
</li>
<ul></ul>
</ol>
&#13;
和pets =上面的JSON数据。第一个ng-repeat工作正常,第二个嵌套在第一个ng-repeat中没有。最初我把它放在一个img标签里面作为ng-src,我认为它与$ sce源保护有关,但是这并不是因为看起来不是这样的
答案 0 :(得分:2)
您缺少媒体类型
<ol><li ng-repeat="pet in pets | orderBy: 'name.$t'">
<div>{{pet.name.$t}} - {{pet.animal.$t}}</div>
<div ng-repeat="pic in pet.media.photos.photo">{{pic.$t}}</div>
</li>
<ul></ul>
</ol>