【发布时间】:2016-09-29 06:18:04
【问题描述】:
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th ng-repeat="header in headers">{{header}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="table in tables">
<td>{{$index+1}}</td>
<td ng-repeat="header in headers">{{$parent.table.header}}</td>
</tr>
</tbody>
</table>
我有一个从服务器检索到的 json 数组。第一个 ng-repeat: 'headers' 包含我提取的那个 json 数组中的键。它在所有情况下都可以正常工作。
第二个 ng-repeat: 'tables' 包含接收到的 json 数组。我想要做的是对于 json 数组的每个元素,通过提供键值来查找数据。
这是我的多个 ng-repeat 代码。这不起作用,表格中没有打印任何数据,但如果我将{{$parent.table.header}} 更改为{{$parent.table}} 或{{header}},我可以在表格中看到数据。
问题是{{$parent.table.header}}我怎样才能正确地做到这一点?
【问题讨论】:
-
不清楚您要在这里输出什么。您能否提供更多信息,特别是您的数据是什么样的,以及您希望在输出中看到什么?
-
在 plunkr 中发布您的代码将用于解决您的问题
标签: html angularjs angularjs-ng-repeat ng-repeat