I Have a html table which is binding using AngularJs.
<tr class="gradeX" ng-repeat="itm in usersList">
<td>
<input type="checkbox" ng-checked="itm.checkstatus == 1" ng-model="itm.selected" value="{{itm.ID}}" /></td>
<td> {{itm.FirstName}}</td>
<td>{{itm.Email}}</td>
</tr>
During ng-repeat i already add a condition that if itm.chekstatus=1 then checkbox will check otherwise not.But now i want to get all selected checkbox id when a button is clicked. here is my code for getting the selected checkboxid.
$scope.AddEvent = function (Data) {
debugger
$scope.UserNameArray = [];
angular.forEach($scope.usersList, function (itm) {
if (itm.selected) $scope.UserNameArray.push(itm.ID);
})
var obj = {
idList: $scope.UserNameArray
}
if ($scope.UserNameArray.length > 0) {
$http({
url: "EventRoute/getAllSelectedUserID",
dataType: 'json',
method: 'POST',
data: obj,
headers: {
"Content-Type": "application/json"
}
}).success(function (response) {
}
})
.error(function (error) {
alert(error);
});
}
}
my problem is that when i add a condition ng-checked="itm.checkstatus == 1" along with ng-model="itm.selected" value="{{itm.ID}}" then i am not getting the selected checkboxid.But when i remove the condition ng-checked="itm.checkstatus == 1" then i am getting the selected checkbox id. How to do this???