ng-class并不像我期望的那样工作

时间:2021-05-05 12:09:43

In ng-grid, I am using the following cell Template,

在ng-grid中,我使用以下单元模板,

cellTemplate: '<div class="ngCellText" ng-class="{\'red\': {{row.getProperty(col.field)}} > 15 , \'yellow\': {{row.getProperty(col.field)}} > 5 && {{row.getProperty(col.field)}} <= 15}">{{row.getProperty(col.field)}} </div>'

However, it does not appear how I expect it to be. Sometimes it applies the class 'red' when the value is 0. I am not sure why it is behaving so.

然而,它似乎并不是我所期望的那样。有时当值为0时,它应用类'red'。我不知道它为什么会这样。

1 个解决方案

#1


2  

ng-class directive doesn't process {{}} interpolation directive

ng-class指令不处理{{{}插值指令

ng-class="{'red': row.getProperty(col.field)}

#1


2  

ng-class directive doesn't process {{}} interpolation directive

ng-class指令不处理{{{}插值指令

ng-class="{'red': row.getProperty(col.field)}