3

I have some checkboxes in HTML:

<input type="checkbox" name="type[]" value="3">
<input type="checkbox" name="type[]" value="4">
<input type="checkbox" name="type[]" value="5">

How I can get all selected values in Angular JS?

I tried to add for earch input: ng-model="type[]"

Alibabaev
  • 61
  • 1
  • 8

1 Answers1

1

Try this:

<div ng-controller="MyCheckbox" 
 ng-init="checkboxes = {1: true, 2: false, 3: true, 4: false}">
    <input type="checkbox" ng-model="checkboxes.1">1
    <input type="checkbox" ng-model="checkboxes.2">2
    <input type="checkbox" ng-model="checkboxes.3">3
    <input type="checkbox" ng-model="checkboxes.4">4
    <br>{{checkboxes}}
</div>

JSFIDDLE DEMO

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331