July 27, 2026
Get Checked Checkboxes with AngularJS

How to Get Selected CheckBoxes Using AngularJs

In this blog, I would teach you two ways to get a list of selelected checkboxes using AngularJS with the click on a button. In another blog we would explain how to perform an action when a checkbox is checked (ng-change or ng-click event).

 

HTML
For the two methods, the html code remains the same as below:

 

<div ng-repeat="row in Skills" >
 <label>
   <input type="checkbox" ng-model="row.selected" >
   <span> {{row.Skill}} </span>
</label>
</div>
<button ng-click="GetSelected()">Get Selected</button>

 

AngularJS (Script 1)

$scope.selected = {};
$scope.DeleteSelected=function () {               
        angular.forEach($scope.selected, function(value, key) {
 console.log(key);
 console.log(value);   
 });
};

 

AngularJS (Script 2)

 

$scope.GetSelected=function() {       
   var selected = [];
   angular.forEach($scope.Skills, function(row) {
   if (row.selected) {          
  console.log(row.ID);
  console.log(row.Skill);
   }
   });
}

 

Both methods have been tested by me and works very fine. You could reach me by comment below if you have any challenge using the code.

 

Thanks for learning.

 

 

kindsonthegenius

Kindson Munonye is a software engineer and technical author covering machine learning, statistics, REST APIs, Python, and software engineering. He publishes free tutorials on The Genius Blog and live classes on Alkademy. GitHub · LinkedIn · About · Alkademy

View all posts by kindsonthegenius →
0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
http://nuochoauk.vn/bo-tui-bi-quyet-lam-dep-da-chuan-spa-cung-vitamin-e.html
http://nuochoauk.vn/bo-tui-bi-quyet-lam-dep-da-chuan-spa-cung-vitamin-e.html
6 years ago

I’m not sure exactly why but this weblog is loading
extremely slow for me. Is anyone else having this problem or is it
a problem on my end? I’ll check back later on and see if the problem still exists.