I have a few checkboxes:(我有几个复选框:)
<input type='checkbox' value="apple" checked>
<input type='checkbox' value="orange">
<input type='checkbox' value="pear" checked>
<input type='checkbox' value="naartjie">
That I would like to bind to a list in my controller such that whenever a checkbox is changed the controller maintains a list of all the checked values, for example, ['apple', 'pear']
.(我想绑定到我的控制器中的列表,这样每当复选框被更改时,控制器都会保留所有已检查值的列表,例如['apple', 'pear']
。)
ng-model seems to only be able to bind the value of one single checkbox to a variable in the controller.(ng-model似乎只能将一个复选框的值绑定到控制器中的变量。)
Is there another way to do it so that I can bind the four checkboxes to a list in the controller?(还有另一种方法可以将四个复选框绑定到控制器中的列表吗?)
ask by nickponline translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…