What is the best way to conditionally apply a class?

后端 未结 22 2235
感动是毒
感动是毒 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:26

    I am new to Angular but have found this to solve my issue:

    
    

    This will conditionally apply a class based on a var. It starts off with a icon-download as a default, the using ng-class, I check the status of showDetails if true/false and apply class icon-upload. Its working great.

    Hope it helps.

提交回复
热议问题