This blog represents code sample to achieve “Check all” or “Select all” using ION-Checkbox.
Say, you have a list of contacts (name) with check boxes. What you want is to achieve “check all” when you check one checkbox. $scope.allcontacts is a temporary object to capture the checkbox checked value.
$scope.allcontacts = {};
$scope.allcontacts.checked = false;
$scope.checkAll = function() {
if ($scope.allcontacts.checked) {
$scope.allcontacts.checked = true;
} else {
$scope.allcontacts.checked = false;
}
for (var i=0; i < $scope.contacts.length; i++) {
$scope.contacts[i].checked = $scope.allcontacts.checked;
};
};
<ion-list>
<ion-checkbox class="item-checkbox-right" ng-model="allcontacts.checked" ng-checked="allcontacts.checked" ng-click="checkAll()">
All Contacts
</ion-checkbox>
<ion-checkbox ng-repeat="contact in contacts"
ng-model="contact.checked"
ng-checked="contact.checked" class="item-checkbox-right">
<h2>{{contact.name}}</h2>
</ion-checkbox>
</ion-list>
Last updated: 2nd May, 2024 The success of machine learning models often depends on the…
When working on a machine learning project, one of the key challenges faced by data…
Last updated: 1st May, 2024 The bias-variance trade-off is a fundamental concept in machine learning…
Last updated: 1st May, 2024 As a data scientist, understanding the nuances of various cost…
Last updated: 1st May, 2024 In this post, you will learn the concepts related to…
Last updated: 26th April, 2024 In this blog post, we will discuss the logistic regression…