【问题标题】:ng-repeat add two row per repeatng-repeat 每次重复添加两行
【发布时间】:2016-05-24 22:02:27
【问题描述】:

我正在使用 ng-repeat 来形成表格中的行。对于每一行,我需要显示一些需要跨越该行所有单元格的数据。

  <tr ng-repeat="cr in results.crs">
    <td>cell 1</td>
    <td>cell 2</td>
  </tr>

我想要这样的东西-

  <tr ng-repeat="cr in results.crs">
    <td>cell 1</td>
    <td>cell 2</td>
    </tr >
      <td colspan=2>The Special Cell</td>
    <tr>
  </tr>

但是,ng-repeat 不允许每次重复两行。我尝试执行以下操作但不起作用。

  <tr ng-repeat="cr in results.crs">
    <td>cell 1</td>
    <td>cell 2</td>
    </tr >
      <td>The Special Cell</td>
    <tr>
  </tr>

有没有办法每次重复添加两行?

另外,任何人都可以提出任何替代方法吗?我正在使用表格结构,因为它更易于设计并且我具有 HTML + CSS 的基本知识。

【问题讨论】:

  • 您应该尝试使用&lt;div ng-repeat=" "&gt; &lt;tr&gt; &lt;td&gt; cell 1&lt;/td&gt;&lt;/tr&gt; &lt;/div&gt; 可能会奏效

标签: angularjs html-table ng-repeat


【解决方案1】:

使用

<tr ng-repeat-start="cr in results.crs">
  <td>cell 1</td>
  <td>cell 2</td>
</tr >
<tr ng-repeat-end>    
  <td>The Special Cell</td>
</tr>

https://docs.angularjs.org/api/ng/directive/ngRepeat

【讨论】:

  • 像魅力一样工作!谢谢@戴夫布什。感谢您的快速响应和帮助!
猜你喜欢
  • 2015-07-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-18
  • 1970-01-01
相关资源
最近更新 更多