使用多次重复

Using multiple ng-repeat

    <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 代码。这不起作用,table 中未打印任何数据,但如果我将 {{$parent.table.header}} 更改为 {{$parent.table}}{{header}},我可以在 table 中看到数据。 问题是 {{$parent.table.header}} 我怎样才能正确地做到这一点?

尝试使用 $parent.table[header] - 因为 header 已经是一个字符串。