What is the best way to conditionally apply a class?

后端 未结 22 2281
感动是毒
感动是毒 2020-11-22 09:12

Lets say you have an array that is rendered in a ul with an li for each element and a property on the controller called selectedIndex.

22条回答
  •  难免孤独
    2020-11-22 09:30

    We can make a function to manage return class with condition

    
    

    And then

    
    
    

    AngularJS ng-class if example

    • {{icolor}}


    Other way using : ng-class="{'class1' : expression1, 'class2' : expression2,'class3':expression2,...}"

    • {{icolor}}

    You can refer to full code page at ng-class if example

提交回复
热议问题