4

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[]"

3

1 Answer 1

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

3
  • How to do name for chekboxes? That in server I have: type[] = 1, type[] = 2
    – Alibabaev
    CommentedApr 20, 2015 at 14:03
  • Why do you need the names for? And what you "have on server" is quite confusing.CommentedApr 20, 2015 at 15:02
  • How I will to prepare data in server if these have not name, for example $_POST['type'][]?
    – Alibabaev
    CommentedApr 21, 2015 at 10:23

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.