我怎样才能遍历键,在NG-重复值的角度 [英] How can I iterate over the keys, value in ng-repeat in angular
问题描述
在我的控制器,我有数据,如: $ scope.object =数据
现在这个数据与键和值的字典从 JSON
。
我可以访问 object.name
在模板的属性。有没有办法,我可以在键盘上迭代,以及和表像
< TR>< TD> {{键}}< / TD> &所述; TD> data.key< / TD>
中的数据是这样的。
{
ID:2,
工程:wewe2012
日期:2013年2月26日
说明:ewew
eet_no:ewew,
}
如何
< TR NG重复=(键,值)数据>
&所述; TD> {{键}}< / TD> &所述; TD> {{}值}< / TD>
< / TR>
这方法被列在文档:<一href=\"http://docs.angularjs.org/api/ng.directive:ngRepeat\">http://docs.angularjs.org/api/ng.directive:ngRepeat
In my controller, I have data like:
$scope.object = data
Now this data is the dictionary with keys and values from json
.
I can access the attribute with object.name
in the template. Is there any way that I can iterate over the keys as well and display them in table like
<tr><td> {{key}} </td> <td> data.key </td>
The data is like this
{
"id": 2,
"project": "wewe2012",
"date": "2013-02-26",
"description": "ewew",
"eet_no": "ewew",
}
How about:
<tr ng-repeat="(key, value) in data">
<td> {{key}} </td> <td> {{ value }} </td>
</tr>
This method is listed in the docs: http://docs.angularjs.org/api/ng.directive:ngRepeat
这篇关于我怎样才能遍历键,在NG-重复值的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!