简体   繁体   English

复杂的json ng-repeat

[英]Complex json ng-repeat

I try to ng-repeat on this object, I tried several times but still stuck. 我尝试对这个对象进行ng-repeat,我尝试了几次,但仍然卡住了。 If anyone have an idea, and if it's possible to share tips for this kind of situation. 如果有人有想法,是否有可能分享这种情况的提示。

[
{
    "Abonnement": {
        "id": "1",
        "nom": "BAS PRIX",
        "tarif": "2.49",
        "communication": "2h de communication",
        "vers": "vers fixes et mobiles",
        "zone": "zone nationale"
    }
},
{
    "Abonnement": {
        "id": "2",
        "nom": "NATIONAL",
        "tarif": "9.99",
        "communication": "t\u00e9l\u00e9phonie et SMS illimit\u00e9s",
        "vers": "vers fixes et mobiles",
        "zone": "zone nationale"
    }
},
{
    "Abonnement": {
        "id": "3",
        "nom": "EURO",
        "tarif": "19.99",
        "communication": "t\u00e9l\u00e9phonie et SMS illimit\u00e9s",
        "vers": "vers fixes et mobiles",
        "zone": "zone EURO"
    }
}
]

If the array is stored in the scope under $scope.abonnements , this is how you would use ng-repeat : 如果数组存储在$scope.abonnements下的作用$scope.abonnements ,这就是使用ng-repeat

<ul>
  <li ng-repeat="item in abonnements">{{ item.Abonnement.nom }}</li>
</ul>

See here: http://jsfiddle.net/89b98cpd/ 看到这里: http : //jsfiddle.net/89b98cpd/

Assuming you have name your object something like Abonnements 假设您已将对象命名为Abonnements

  $scope.Abonnement = [..your example json]

Then you'd just use the ng-repeat like 然后你就可以像这样使用ng-repeat

  <div ng-repeat="Abonnement in Abonnements">
      id: {{Abonnement.Abonnement.id}}
  </div>

And access the information with Abonnement.Abonnement.id for example. 例如,使用Abonnement.Abonnement.id访问信息。 So if you wanted the vers, it would be Abonnement.Abonnement.vers . 因此,如果您想要版本,那就是Abonnement.Abonnement.vers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM