How do I bind to list of checkbox values with AngularJS?

前端 未结 29 2188
天涯浪人
天涯浪人 2020-11-22 05:20

I have a few checkboxes:





        
29条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 06:07

    You don't have to write all that code. AngularJS will keep the model and the checkboxes in sync simply by using ngTrueValue and ngFalseValue

    Codepen here: http://codepen.io/paulbhartzog/pen/kBhzn

    Code snippet:

    {{item.id}} Click this to change data value below

    {{list1 | json}}

提交回复
热议问题