How to add/remove a class to the parent element of a checkbox on change in Angular js

后端 未结 1 1572
猫巷女王i
猫巷女王i 2021-01-15 02:09

I have a list with checkbox items in it, On selecting the checkbox I want to add a class to the parent li. How can I achieve this.

I am new to Angular.



        
1条回答
  •  无人及你
    2021-01-15 02:38

    You can do this with ng-class:

    • Orange

    The {active: orange} is saying, "only add the active class if orange is truthy."

    ng-model two-way binds the value of the checkbox. This gives you a variable orange to use inside the angular context.

    0 讨论(0)
提交回复
热议问题