【问题标题】:How to add background color to particular row using pagination如何使用分页向特定行添加背景颜色
【发布时间】:2017-01-03 20:06:01
【问题描述】:

这里我使用分页遍历数组。数组中有 count 变量,可以通过{{x.count}}访问。我需要为 count=0 的行添加背景颜色。

如图所示...我需要在 count=0 的行中显示不同的颜色

【问题讨论】:

  • 我需要整行的背景色,而不是特定的 td
  • 如果所有行的array.count为0会发生什么?
  • 其实如果count=0意味着我没有访问过那一行,所以我需要给count=0的那一行添加一些背景色

标签: angularjs pagination


【解决方案1】:

您可以将 css 与类表达式结合使用:

<tr dir-paginate="x in array" class="count-{{ x.count }}">
    <td scope="row">{{x.emailTo}}</td>
    <td scope="row">{{x.subject}}</td>
</tr>

CSS:

tr.count-0 td {
    background-color: green;
}

JSFIDDLE

【讨论】:

    【解决方案2】:

    这是另一种方法,您可能会发现它更“有棱角”:

    <tr dir-paginate="x in array"
      ng-class-odd="'some-odd-class'"
      ng-class-even="'some-even-class'">
    </tr>
    

    ng-class-odd/ng-class-even 仅适用于 ng-repeat,因此我假设(希望)您的 dir-paginate 指令在某处有一个 ng-repeat。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 2016-05-28
      相关资源
      最近更新 更多