2016-12-02 73 views
1

更新NG风格我有一个ng-style内的ng-repeat。问题是ng-style值在更改后更新,但实际样式不会更改。如何NG重复

<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被更新。此更新未反映在该样式中。

回答

1

无需使用{{...}}为你的CSS,它已经内的角度,因为你正在使用NG-风格。

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