I am trying to get the list of selected checkboxes using angularjs. But unable to get selected.
HTML code Here
<input type="checkbox" id="product_" class="form-control" ng-model="x.Selected">
</div>
<div class="item-name">
</div>
</div>
script code:
.controller('categorieCtrl', function($scope, $http) {
$scope.result = [{
id: 1,
category_name: 'Apple',
Selected: false
}, {
id: 2,
category_name: 'Mango',
Selected: false
}, {
id: 3,
category_name: 'Orange',
Selected: false
}];
$scope.myFunc = function () {
debugger;
var message = "";
for (var i = 0; i < 3; i++) {
if ($scope.result[i].Selected) {
var id = $scope.result[i].id;
var categoryName = $scope.result[i].category_name;
message += "Value: " + id + " Text: " + categoryName + "\n";
}
}
alert(message);
};
});
In the above code i am not getting selected items. Please let me know how can i get selected items using angularjs.
Aucun commentaire:
Enregistrer un commentaire