在字典AngularJS中检索密钥

时间:2014-09-10 07:25:24

标签: javascript json angularjs

我想在AngularJS中找到我的字典的根密钥。 这是我的代码:http://jsbin.com/vidihucihexo/1/edit

我想显示" aUniqueID1"如果我做" {{match.matchs}}"它显示:

{
    "aUniqueID1":{
        "date":"2014-09-07 13:00:00",
        "guest_player":"Me",
        "host_player":"Tom",
        "odds":{
            "guest":"2.80",
            "host":"2.25",
            "null":"2.85"
        },
        "score":"0 - 0"
    },
    "aUniqueID2":{
        "date":"2014-09-07 18:30:00",
        "guest_player":"Bryan",
        "host_player":"Me",
        "odds":{
            "guest":"3.25",
            "host":"1.98",
            "null":"2.95"
        },
        "score":"0 - 0"
    }
}

我只想显示值键aUniqueID1(此文字,而非字典)。

想法? 谢谢:))

1 个答案:

答案 0 :(得分:3)

试试这个:

  <li class="item" ng-repeat="(key, item) in match.matchs">
    {{key}} 
    {{item.host_player}} vs {{item.guest_player}}
  </li>

Here is您修改后的代码