[英]How to get json keys using angularjs ng-repeat?
I have a json and I want to iterate and get the json keys: Testing01
, Testing02
and Testing03
on my ng-repeat for my given json. 我有一个json,我想对其进行迭代并获取json键:对于给定的json,在ng-repeat上显示
Testing01
, Testing02
和Testing03
。 How can I get it using ng-repeat ? 如何使用ng-repeat获得它? Please let me know and thanks in advance.
请让我知道并提前致谢。
You could do it like this: 您可以这样做:
<div ng-controller="MyCtrl">
<table>
<tr ng-repeat="(key,value) in data.testingjson">
<td> {{key}}: {{value}} </td>
</tr>
</table>
</div>
Updated Fiddle: https://jsfiddle.net/0gucxcq2/6/ 更新的小提琴: https : //jsfiddle.net/0gucxcq2/6/
<div ng-controller="MyCtrl">
<table>
<tr ng-repeat="(key, data) in data.testingjson track by $index">
<td> {{key}} </td>
</tr>
</table>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.