Is there a way for me to retrieve a specific record within an ngRepeat
loop from the controller, particularly for form validation purposes?
Here is a form where users can dynamically add or remove records:
<table class="table table-condensed span12" id="tableParticipants">
<!-- snip -->
<tbody>
<tr ng-repeat="person in people">
<td><input type="text" pattern="[0-9]*" data-provide="typeahead" placeholder="8675309" ng-model="person.empid"></td>
<td><input type="text" data-provide="typeahead" placeholder="Firstname Lastname" ng-model="person.name"></td>
<td><input type="text" placeholder="Title" ng-model="person.title"></td>
<td style="text-align: center"><i class="icon-remove" ng-click="removeParticipant()"></i></td>
</tr>
</tbody>
</table>
During form submission, I need to validate that all employee IDs are correct to avoid any database errors. Therefore, as I iterate through the loop:
$scope.people.forEach(function(element, index, array)
{
if ($element['empid'] == BAD)
{
// flag the corresponding ngRepeat row as erroneous
}
}
What is the best approach to access a specific row for a particular record in this scenario?