I have a $resource object in Angular that looks like this:
{
_id: '1'
items: [
{_id: 'a'}, {_id: 'b'}, {_id: 'c'}
]
}
My goal is to create a form with a checkbox for each element in the items
array. In the act()
function, I want to be able to identify which elements were selected using the checkboxes.
The HTML markup for the form is as follows:
<form ng-submit="act()">
<input type="checkbox" ng-model="item._id" ng-repeat="item in items">
<button type="submit">Submit</button>
</form>
However, I am struggling to access the array of item ids corresponding to the checked checkboxes within the act()
function in the controller.
I have attempted to retrieve the values from the FormController in the scope, but I can only get the validity state from there. I have also tried binding the checkboxes to an array in the scope using ng-model
, but it always remains empty in the act()
function.