如何使用angularjs ng-repeat获取json键



我有一个json,我想迭代并获得json键:Testing01, Testing02Testing03在我的ng-repeat上为我给定的json。我怎么用ng-repeat得到它?请提前让我知道并感谢。

<div ng-controller="MyCtrl">
 <table>
   <tr ng-repeat="(key, data) in data.testingjson track by $index">
      <td> {{key}} </td> 
    </tr>
  </table>
</div>

你可以这样做:

<div ng-controller="MyCtrl">
     <table>
       <tr ng-repeat="(key,value) in data.testingjson">
          <td> {{key}}: {{value}} </td> 
        </tr>
      </table>
</div>

更新小提琴:https://jsfiddle.net/0gucxcq2/6/

就这么做

<div ng-controller="MyCtrl">
 <table>
    <tr ng-repeat="(key,value) in data.testingjson">
          <td> {{key}}  </td> 
        </tr>
  </table>
</div>

小提琴

最新更新