Ng-style with condition

后端 未结 7 1491
旧巷少年郎
旧巷少年郎 2021-01-11 09:25

How can I apply style on some item in a list that satisfy listed condition:

        
7条回答
  •  离开以前
    2021-01-11 10:09

    ng-style="{'background': (desktop) ? '#ffffff' : ''}"
    

    Explanation: {CssProperty: Condition ? if condition is True : If condition is False}

    CssProperty : meaning background, color, font-size etc..

    Condition: just like a If statment..

    after the : define the property value for the true and false Condition .for the the CssProperty.

    here we have no value if condition is false.

    any true or false value should be the Proper value for the CSSProperty. So for background it's #ffffff or White.

提交回复
热议问题