【问题标题】:angular js ng-repeat issues inside htmlhtml中的角度js ng-repeat问题
【发布时间】:2016-04-23 08:30:39
【问题描述】:

我现在也有这样的。

<tr ng-repeat="a in xx">
  <td>Name</td>
  <td>{{a.name}}</td>

</tr>
<tr ng-repeat ="b in kk">
   <td>Id</td>
   <td>{{b.ll}}</td>
</tr>

但我需要一个 tr 内的两个循环。意思是,我需要一个 tr 内的 4 个 td。 我该怎么做。

【问题讨论】:

  • 您想将“Name”、“a.name”、“Id”和“b.ll”都放在一个表格行中吗?
  • 是的。但是两个数组中的条目数可能会有所不同。

标签: php html angularjs


【解决方案1】:

您需要回复 $index 以引用第二个数组:

<tr ng-repeat="a in xx">
  <td>Name</td>
  <td>{{a.name}}</td>
  <td>Id</td>
  <td>{{kk[$index].ll}}</td>
</tr>

【讨论】:

  • 是的。我知道了,但是如果第二个循环中的条目数更多,那么这将无法正常工作。我会错过一些数据。
  • 您能提供确切的数据示例吗?它应该可以工作,您必须相应地操作索引值,而且数组 kk (或内部循环数组)应该具有预定义的已知值,例如至少应该提前知道计数。然后,您可以相应地添加 [$index]+1....+2...等。
猜你喜欢
  • 1970-01-01
  • 2015-07-05
  • 2015-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多