Tutorialsplane

AngularJs get checkbox value


AngularJs get checkbox value – While using the html form input elements we sometimes need checkboxes. It is very simple to get the selected(checked) checkbox value in angularjs. Here in this tutorial we are going to explain how you can get the selected checkbox value. You can also use our online editor to edit and run the code online.


AngularJs get checkbox value | Selected Checkbox | Example

Let us go step by step to get the checked checkbox value-

JavaScript Part

JavaScript Part Contains the following part as below –

AngularJs get checkbox value in controller:

 

Html Part

Html Part contains the following html as below –

AngularJs get checkbox value in View:


<div ng-app="myApp">  
<div ng-controller="myController">  

 <p>Selected Checkboxes = {{selectedCheckboxes | json}}</p>
<p>Value1 = {{selectedCheckboxes.value1}}</p>
<p>Value2 = {{selectedCheckboxes.value2}}</p>
<p>Value3 = {{selectedCheckboxes.value3}}</p>
<p>Value4 = {{selectedCheckboxes.value4}}</p>
 
</div> 
</div>

Complete Part

Now let us combine both html and JavaScript parts –

Angularjs get multiple checkbox value Example:




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  

 <p>Selected Checkboxes = {{selectedCheckboxes | json}}</p>
<p>Value1 = {{selectedCheckboxes.value1}}</p>
<p>Value2 = {{selectedCheckboxes.value2}}</p>
<p>Value3 = {{selectedCheckboxes.value3}}</p>
<p>Value4 = {{selectedCheckboxes.value4}}</p>
 
</div> 
</div>
  
      
                                                        

Try it »

If you run the above example it will produce output something like this –