【问题标题】:Using rowspan in table with AngularJS在 AngularJS 中使用表中的行跨度
【发布时间】:2017-03-17 16:43:51
【问题描述】:

我想插入一个包含两列的表,其中第一列包含多行,第二列应包含单行。为此,我编写了如下代码。

<tr ng-repeat="x in data">
  <td><a href="#">{{ x.no }}</a></td>
  <td ng-if="this.rowIndex === 0" rowspan='{{x.length}}'> ok </td>
</tr>

其中 data 是一个 JSON 对象数组,其中包含一个名为 no 的属性。在这里使用 this.rowIndex 是正确的还是我在这里犯了错误。

【问题讨论】:

    标签: angularjs html-table


    【解决方案1】:

    您必须使用来自ng-repeat 指令的变量$index(请参阅documentation)。 此外,您读取了x 对象的长度;我相信您打算使用 data 变量这样做。

    你可以在这个codepen看到结果。

    【讨论】:

      猜你喜欢
      • 2019-08-01
      • 2018-11-26
      • 1970-01-01
      • 2018-11-09
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      • 2015-05-18
      相关资源
      最近更新 更多