컨트롤러에서 ngRepeat
루프 내의 지정된 레코드에 액세스하려면 어떻게해야합니까? 궁극적으로 폼 유효성 검사를 위해 어떻게합니까?ngRepeat의 요소 액세스
I는 사용자가 제거 동적으로 추가 기록을 가질 수있는 다음과 같은 형식으로 /이 : 나는 직원 ID가 유효한지 확인해야 양식을 제출하기에
<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>
을, 다른 나는 데이터베이스를 얻을 것이다 오류. 따라서 루프를 통해 작업 할 때 :
$scope.people.forEach(function(element, index, array)
{
if ($element['empid'] == BAD)
{
// set corredponding ngRepeat row to error
}
}
특정 레코드에 대해 해당 행에 어떻게 액세스합니까?
왜 그렇게해야합니까? 당신은 오류 메시지와 함께 사람들의 배열을 채울 수 있으며, UI가 있다면 그것을 보여줄 수 있습니다 ... – lucuma