I have a table in my account statement with dates and two columns containing checkboxes.
View (HTML)
<table>
<tr>
<th>Statement Period</th>
<th>Mail Address</th>
<th>Email Address</th>
</tr>
<tr>
<td>Oct 2018</td>
<td><input type="checkbox"></td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>Nov 2018</td>
<td><input type="checkbox"></td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>Dec 2018</td>
<td><input type="checkbox"></td>
<td><input type="checkbox"></td>
</tr>
</table>
<button ng-click="getSelectedData">Proceed</button<
Using the $index (array ID), I need to extract the selected checkboxes from each row and compile them into an array in JSON format;
Note: "Y" represents a selected checkbox, while "N" represents an unselected checkbox
JSON Array (Expected Response)
[
{
"isEmail": "Y",
"isMail": "N",
"month": "12",
"year": "2018"
},
{
"isEmail": "Y",
"isMail": "N",
"month": "10",
"year": "2018"
}
]
I am struggling to achieve this using a POST request with parameters for email address and physical address. I've attempted a loop but without success.
Controller JS
$scope.sendStatementList = function(i) {
var listLength = $scope.accountStatementList.length;
for (var i = 0; i < listLength; i++) {
var selectedItem = $scope.accountStatementList[i];
return selectedItem;
}
console.log(selectedItem);
};
I have tried various methods but still haven't found the right solution. Any assistance would be greatly appreciated.
P.S. Here is a plunker (demo) showcasing my issue.