我怎样才能遍历键,在NG-重复值的角度 [英] How can I iterate over the keys, value in ng-repeat in angular

查看:143
本文介绍了我怎样才能遍历键,在NG-重复值的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的控制器,我有数据,如:
$ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆