【问题标题】:How to update ng-style in ng-repeat如何在 ng-repeat 中更新 ng-style
【发布时间】:2016-12-02 21:32:19
【问题描述】:

我在ng-repeat 中有一个ng-style。问题是 ng-style 值在更改后更新,但实际样式没有改变。

<tr class="row" ng-repeat="(hourIndex, hour) in day track by $index">
  <td class="cell"
      ng-style="{ 'background-color': '{{ switchBackgroundColor(hour) }}' }">
    {{ hour }}%
  </td>
</tr>

如上所述,每天一次,然后小时更改,ng-style 会更新。此更新未反映在样式中。

【问题讨论】:

    标签: angularjs ng-style


    【解决方案1】:

    您的 css 无需使用 {{...}},因为您使用的是 ng-style,所以它已经在 angular 范围内。

    <tr class="row" ng-repeat="(hourIndex, hour) in day track by $index">
        <td class="cell" ng-style="{ 'background-color': switchBackgroundColor(hour) }">
            {{ hour }}%
        </td>
    </tr>
    

    【讨论】:

      猜你喜欢
      • 2014-08-15
      • 1970-01-01
      • 2013-07-10
      • 2013-06-24
      • 2016-07-10
      • 2014-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多