Tutorialsplane

Angularjs set checkbox checked


Angularjs set checkbox checked : There are many ways to set checkbox checked on button click. You can use ng-checked to check a checkbox in AngularJs. Here in this tutorial we are going to explain how you can set checkbox checked in AngularJs. You can also use our online tool to run and edit the code.


Angularjs set checkbox checked on Button Click Example

You can set checkbox checked on button click as below-

JavaScript Part –

JavaScript Part Contains the following script –

Angularjs set checkbox checked on Button Click : JavaScript

 

Html Part-

Html Part Contains the following html –

Angularjs set checkbox checked on Button Click:

<div ng-app="myApp">  
<div ng-controller="myController">  
	
    <button ng-click="checkBoxChecked()" ng-model="master">Click to Check </button>
	<br/>
	 
	<br/>
	
</div> 
</div>

Complete Example-

Now let us combine both javascript and html parts. Here is the complete example –

How to set checkbox checked on Button Click Example:




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  
	
    <button ng-click="checkBoxChecked()" ng-model="master">Click to Check </button>
	<br/>
	 
	<br/>
	
</div> 
</div>
  

Try it »

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