嵌套的重复,一个依赖于另一个
nested ng-repeat that one depend on the other
我有一个问题与角,我想在数据表中使用两个嵌套的ng-repeat,其中第一个获得数据,第二个获得要从数据中检索的字段名称(在第一个ng-repeat中检索)
下面是我尝试做的代码:
<table md-table flex-order-gt-sm >
<thead md-head>
<tr md-row >
//1st : get the name of fields, not a problem
<th md-column ng-repeat="field in fields">{{item.name}}</th>
</tr>
</thead>
<tbody md-body>
<tr md-row ng-repeat="item in items">
<td md-cell ng-repeat="field in fields" >
//here is the problem I want to get the item that it's field name is field
{{item.{{field}} }}</td>
</tr>
</tbody>
</table>
例如,如果字段包含:{'a','b','c'}
条目包含{'a':'1','b':'2','c':'3'};
例如,对于{{item的第一次迭代。{{字段}}}}返回1
使用toString()
检索作用域对象中的作用域数据
<tr md-row ng-repeat="item in items">
<td md-cell ng-repeat="field in fields" >
{{item[field.toString()]}}
</td>
</tr>
这是活塞
作为一种选择,你也可以使用过滤器:
<td md-cell ng-repeat="field in fields | filter: { name: 'field' }">
</td>
您需要根据项目收集后的项目获取字段收集
getFieldsByItem(项目)
那么你可以从fields集合中获取字段{{领域}}
相关文章:
- 如何隐藏&使用jQuery禁用依赖于另一个字段值的字段
- 如何使用 2 个 XMLHttpRequest 一个依赖于另一个
- Javascript表单.使一个条目依赖于另一个条目
- 试图使一个事件依赖于另一个事件,并使用jquery自定义事件传递数据
- 使用jquery如何自动删除下拉列表中的第一个空白选项(如果它依赖于另一个选项)
- 测试依赖于另一个指令Angularjs的指令
- 创建一个不依赖于Snap实例的组
- 使计算属性依赖于emberjs中另一个对象的所有属性
- 打开一个模态(在Codeigniter中),该模态从依赖于phpvar的URL加载(在iframe中)内容
- 是否有一个不依赖于 AngularJS 以外的其他框架的 angular 拆分窗格库
- 下拉选项依赖于另一个下拉选项(所有值都来自数据库)
- 如何只运行一个函数一次,然后运行另一个依赖于相同元素的函数
- 创建一个依赖于可观察量“树”的 Knockout 绑定处理程序
- 检查可见性并使用jquery/javascript添加一个类,但不能依赖于滚动事件
- 在Angular2中添加一个依赖于组件名的外部Javascript文件
- 多个Ajax请求的结果,一个依赖于其他Ajax输出
- 嵌套的重复,一个依赖于另一个
- 多个选择选项一个依赖于另一个
- 生成一个依赖于递归承诺的承诺
- 我想定义一个css样式表或添加一个依赖于视口大小的主体类