2016-12-02 89 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>