How can I bind checkboxes to an array in my model, so that the array always contains just the values corresponding to the selected checkboxes?
For example, instead of:
"groups": { "name1": true, "name2": false, "name3": true }
I need to get:
"groups": [ "name1", "name3" ]
I browsed through a lot of questions and some answers suggested using ng-true for getting custom values, but that does not solve the problem, because then I get:
"groups": { "name1": 'CustomvalueIset', "name2": 'CustomValueIset', "name3": 'CustomValueIset' }
My current code looks like this:
<div class="form-group">
<label class="control-label" for="group">Groups</label><br/>
<label class="checkboxes-br" data-ng-repeat="group in groups">
<input type="checkbox" id="group" data-ng-model="model.groups[group.name]">
{{group.name}}
</label>
</div>
groups: {'Valuename', 'Valuename2'}" is both unclear and uses invalid syntax.)"groups": [ "Valuename", "Valuename2" ]as an array?