2017-04-08 3 views
1

私は、上記のデータの中にサブリストを持つリストに読み込んでいるJSONデータをいくつか持っています。 JSONデータは他のng-repeatの中でng-repeat

 "pet": [ 
 
     { 
 
      "options": { 
 
      "option": [ 
 
       { 
 
       "$t": "hasShots" 
 
       }, 
 
       { 
 
       "$t": "altered" 
 
       }, 
 
       { 
 
       "$t": "housetrained" 
 
       } 
 
      ] 
 
      }, 
 
      "status": { 
 
      "$t": "A" 
 
      }, 
 
      "contact": { 
 
      "phone": { 
 
       "$t": "emails only please" 
 
      }, 
 
      "state": { 
 
       "$t": "NC" 
 
      }, 
 
      "address2": { 
 
       
 
      }, 
 
      "email": { 
 
       "$t": "[email protected]" 
 
      }, 
 
      "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" 
 
      } 
 
     }   
 
     ] 
 

と私のコードを呼び出しますを使用してAPIから引かれる上記のJSONデータ=

<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>

やペットです。最初のng-repeatはうまくいきます。最初のng-repeatはネストされていません。もともと私はそれをng-srcというimgタグの中に入れていましたが、$ sceソース保護と関係があると思っていましたが、どちらもうまくいきません。

+0

もっと正確になりますか? 「うまくいかない」とはどういう意味ですか?何を試しましたか?今あなたが持っている結果は何ですか?あなたが期待している結果は何ですか? – Sorikairo

+0

私はちょうど私が写真のリストを正しく返すことができるかどうかを調べるためにテストしました。最終的に私はナビゲートすることができるギャラリーを持っていたが、私は配列が混ざっていることに気づいた。 – Walt

答えて

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> 
+0

ありがとう、私はそれが好きだったが、私はpet.media.photosとしてそれを持っていたことに気付き、それはpet.media.photos.photoである必要があった。私はアホです – Walt

関連する問題