【问题标题】:Changing the color of font depending on math expression within ng-style根据 ng-style 中的数学表达式更改字体颜色
【发布时间】:2016-09-30 11:05:28
【问题描述】:

当我在文本框中输入数字时,我想根据输入的值将下面另一个文本框的文本着色为红色,但我不确定我的 ng-style 语法是否正确关于数学表达式。感谢您的帮助!

ng-model="approval.groupCreditLimit" ng-style="{'color':(approval.siteTotal +approval.siteCreditLimit) >approval.groupCreditLimit) ? 'red' : 'inherit'}" class="form-control" name="groupCreditLimit" placeholder="集团信用额度" >

【问题讨论】:

    标签: javascript css angularjs


    【解决方案1】:

    试试这样的

    ng-style="( (approval.siteTotal + approval.siteCreditLimit) > approval.groupCreditLimit) ? {'color': 'red'} : {'background-color': 'inherit'}" 
    

    here 是一个工作演示

    【讨论】:

    • 感谢您的帮助!!
    • 没问题。如果此答案正确,请不要忘记将其标记为正确答案。干杯!!!!
    猜你喜欢
    • 2016-04-16
    • 2015-12-06
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-12
    • 1970-01-01
    相关资源
    最近更新 更多