ItSolutionStuff.com

AngularJS Check and Uncheck All Checkboxes Example

By Hardik Savani • November 5, 2023
Angular

In this post, i would like to show you how to check uncheck checkboxes in angularjs. we mostly require to do check unselect all checkbox when we are doing multiple select items, multiple delete item etc task on your web app.

Here, i will show you two way to make all checkbox checked and unchecked on button click event in angular js. i also give you demo. so you can check also there. we will use ng-model and ng-checked for doing simple check uncheck toggle event. in another example we will use ng-checked and ng-click. So let's see both example.

Example 1:

<!doctype html>

<html>

<head>

<title>Check and uncheck all checkbox using Angularjs - ItSolutionStuff.com</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

</head>

<body ng-app='myapp'>

<div ng-controller="myCtrl">

<input type='checkbox' value='' ng-model='checkAll' >Check/Uncheck All<br/>

<input type='checkbox' ng-checked="checkAll" >AngularJS<br/>

<input type='checkbox' ng-checked="checkAll">VueJS<br/>

<input type='checkbox' ng-checked="checkAll">JQuery<br/>

<input type='checkbox' ng-checked="checkAll" >PHP<br/>

</div>

</body>

<script type="text/javascript">

var app = angular.module('myapp', []);

app.controller('myCtrl', ['$scope', '$http', function ($scope, $http) {

}]);

</script>

</html>

Example 2:

<!doctype html>

<html>

<head>

<title>Check and uncheck all checkbox using Angularjs - ItSolutionStuff.com</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

</head>

<body ng-app='myapp'>

<div ng-controller="myCtrl">

<input type='button' id='but_checkall' value='Check all' ng-click='checkAll()'>

<input type='button' id='but_uncheckall' value='Uncheck all' ng-click='uncheckAll()'>

<br/>

<input type='checkbox' ng-checked="checkall" >AngularJS<br/>

<input type='checkbox' ng-checked="checkall">VueJS<br/>

<input type='checkbox' ng-checked="checkall">JQuery<br/>

<input type='checkbox' ng-checked="checkall" >Laravel<br/>

</div>

</body>

<script type="text/javascript">

var app = angular.module('myapp', []);

app.controller('myCtrl', ['$scope', '$http', function ($scope, $http) {

$scope.checkAll = function(){

$scope.checkall = true;

}

$scope.uncheckAll = function(){

$scope.checkall = false;

}

}]);

</script>

</html>

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

AngularJS Drag and Drop Table Rows Example with Demo

Read Now →

PHP AngularJS Populate Dynamic Dropdown Example

Read Now →

PHP AngularJS Add Remove Input Fields Dynamically Example

Read Now →

AngularJS Ajax Autocomplete Using Typeahead in PHP Example

Read Now →

How to Copy to Clipboard without Flash in AngularJS?

Read Now →

How to Render HTML Value in Ng-repeat in AngularJS?

Read Now →

AngularJS Scroll to a Specific Element using Anchorscroll

Read Now →

AngularJS Convert Comma Separated String to Array Example

Read Now →

AngularJS Display Default Image If Original Does Not Exists Example

Read Now →

AngularJS Update Bind Ng-model Input Value from JQuery Example

Read Now →

How to Call AngularJS Controller Function in JQuery?

Read Now →

How to Remove # from URL in AngularJS?

Read Now →

AngularJS Image Upload with Preview Example

Read Now →

AngularJS Simple Datepicker Directive Example Tutorial

Read Now →