【问题标题】:Add a class by checking a condition in angular 6通过检查角度 6 中的条件来添加类
【发布时间】:2019-06-18 05:37:45
【问题描述】:

如果'emp_code''emp' 中的值相同,我需要添加一个类'test1'

我已经尝试过使用代码,

class="{{ emp_empcode == emp ? 'test1' : 'test2' }}"

我曾尝试使用 thisthis

还有什么办法吗?提前非常感谢。

【问题讨论】:

    标签: angular6


    【解决方案1】:
    [class.test1]="emp_code == emp"
    

    应该绝对有效。更多品种也可以关注https://toddmotto.com/ng-class-angular-classes

    【讨论】:

    • 很高兴,我能帮上忙 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    • 2019-02-03
    相关资源
    最近更新 更多