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?
then button for action
and then in controller
here is the implemented plunker
You can use the
ng-model
directive to directly bind a property to the element.e.g.
This will update your model.
From this you will be able just to check the values within your model and see which are checked.
e.g.
Check out the documentation for ngModel. Also the ToDo list example on the angularjs.org homepage demonstrates this.
p.s. On a side note, you can also make your angular directives html5 friendly by adding
data-
before. e.g.data-ng-model="X.Item.Id"