【问题标题】:ng-class is not working as I expect it to beng-class 没有像我预期的那样工作
【发布时间】:2015-08-25 03:01:00
【问题描述】:

在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>'

但是,它看起来并不像我期望的那样。有时它会在值为 0 时应用“红色”类。我不确定它为什么会这样。

【问题讨论】:

    标签: javascript css angularjs ng-grid ng-class


    【解决方案1】:

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

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

    【讨论】:

    • 也可以去掉转义符ng-class="{'red': row.getProperty(col.field)}"
    • @John 很高兴帮助你.. 谢谢 :)
    猜你喜欢
    • 2016-06-19
    • 2013-04-11
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 2023-01-01
    • 2014-06-28
    • 2020-08-24
    • 2017-09-26
    相关资源
    最近更新 更多