angular ng重复嵌套json

时间:2016-03-22 11:14:36

标签: angularjs json twig

我想知道如何在这个JSON对象中重复匹配。我已经尝试过各种各样的方法,但是没有运气。

<tr ng-repeat="game in game.competition.season.round.match">
  <td>{% verbatim %}{{ game["@attributes"].match_id }}{% endverbatim %}</td>
</tr> 

当我在ng-repeat中使用整个对象时,我可以获得第一个“@attributes”键的值,但无法进行匹配。

非常感谢任何帮助。

[
  {
    "@attributes": {
      "id": "1",
      "name": "World",
      "last_updated": "2016-03-22 06:22:49"
    },
    "competition": {
      "@attributes": {
        "id": "19",
        "name": "Sony",
        "area_id": "203",
        "area_name": "USA",
        "last_updated": "2016-03-22 09:19:52"
      },
      "season": {
        "@attributes": {
          "season_id": "3628",
          "name": "2016",
          "start_date": "2016-03-21",
          "end_date": "2016-04-03",
          "draw_size": "64",
          "active": "yes",
        },
        "round": [
          {
            "@attributes": {
              "round_id": "21868",
              "title": "1/128 Final",
              "start_date": "2016-03-22",
              "end_date": "2016-03-26",
              "groups": "0",
              "last_updated": "2016-03-22 06:22:49"
            },
            "match": [
              {
                "@attributes": {
                  "match_id": "155624",
                  "official_start_date": "2016-03-22",
                  "official_start_time": "14:00:00",
                  "actual_start_date": "",
                  "actual_start_time": "",

                }
              },
              {
                "@attributes": {
                  "match_id": "155625",
                  "official_start_date": "2016-03-22",
                  "official_start_time": "14:00:00",
                  "actual_start_date": "",
                  "actual_start_time": "",
                  "winner": "yet unknown",
                  "score_A": "",
                  "score_B": "",
                  "status": "Fixture",
                  "drawposition": "38",
                  "person_A_id": "14688",
                }
              },
              {
                "@attributes": {
                  "match_id": "155626",
                  "official_start_date": "2016-03-22",
                  "official_start_time": "14:00:00",
                  "actual_start_date": "",
                  "actual_start_time": "",
                  "winner": "yet unknown",
                  "score_A": "",
                  "score_B": "",
                }
              },
              {
                "@attributes": {
                  "match_id": "155627",
                  "official_start_date": "2016-03-22",
                  "official_start_time": "14:00:00",
                  "actual_start_date": "",
                  "actual_start_time": "",
                  "winner": "yet unknown",
                  "score_A": "",
                }
              },
              {
                "@attributes": {
                  "match_id": "155628",
                  "official_start_date": "2016-03-22",
                  "official_start_time": "14:00:00",
                  "actual_start_date": "",
                  "actual_start_time": "",
                  "winner": "yet unknown",
                  "score_A": "",
                  "score_B": "",
                }
              },
              {
                "@attributes": {
                  "match_id": "155629",
                  "official_start_date": "2016-03-22",
                  "official_start_time": "14:00:00",
                  "actual_start_date": "",
                  "actual_start_time": "",
                  "winner": "yet unknown",
                  "score_A": "",
                  "score_B": "",
                }
              }
            ]
          }
        ]
      }
    }
  }
]

1 个答案:

答案 0 :(得分:1)

应该是这样的,

  <table>
    <tr ng-repeat="game in game[0].competition.season.round[0].match">
  <td>{% verbatim %}{{ game["@attributes"].match_id }}{% endverbatim %}</td>
</tr>

  </table>
相关问题