Angular获取选中的CheckBoxes [英] Angular Get Selected CheckBoxes
本文介绍了Angular获取选中的CheckBoxes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用angular的动态填充复选框列表。
I have a list of dynamically filled checkboxes using angular.
<div ng-repeat="X in XList">
<label>{{X.Header}}</label>
<input type="checkbox" name="X" value="{{X.Item.Id}}" />
<p>{{X.Header}}</p>
</div>
我想要一种方法来检索所有选中复选框的列表。
通常我会使用
I want a method to retrieve a list of all the selected checkboxes. Usually I'd use
$('input[name=checkboxlist]:checked').each(function()
{
}
但这是不可接受的角度.. ..那么有适当的方法吗?
But this is not acceptable with angular .... So is there an appropriate Method to do so?
推荐答案
这里是实现的plunker
<input type="checkbox" ng-model="selected[record.Id]"> {{record.Id}}
$scope.ShowSelected = function() {
console.log($scope.selected);
alert(JSON.stringify($scope.selected));
};
这篇关于Angular获取选中的CheckBoxes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文