我正在使用 Angular 2,我想分别验证每一行中的控件。但我没有办法做到这一点。我希望它只使用反应形式而不是使用模板驱动的方法来完成。我想要 [formGroup] 在每个<tr>
. 任何帮助将不胜感激。下面是我的代码结构:
<tbody *ngFor="let single of allTeamDetails"
[ngClass]="{'alternate-row-color': $even}">
<tr>
<td class="td-data first-column">
<input type="text" class="input-text form-control"
[value]="single.first_name">
</td>
<td class="td-data second-column">
<input type="text" class="input-text form-control"
[value]="single.last_name">
</td>
<td class="td-data third-column">
<input type="email" class="input-text form-control"
[value]="single.email">
</td>
<td class="td-data fourth-column">
<select class="selection-dropdown width-80-percent"
[value]="single.user_role">
<option *ngFor="let singleRole of allUserRole"
value="{{singleRole.name}}">
{{setUserRoleAndType(singleRole.name)}}</option>
</select>
</td>
<td class="td-data fifth-column" >
<input type="password" class="input-text form-control">
</td>
<td class="td-data sixth-column" >
<input type="password" class="input-text form-control">
</td>
<td class="td-data save-send-tm-data">
<button class="btn save-user-details save-sub-account-details"
type="button" data-toggle="tooltip" title="Save">
<i class="fa fa-floppy-o" aria-hidden="true"></i>
</button>
</td>
<td class="td-data save-send-tm-data">
<button type="button"
class="btn save-user-details save-sub-account-details"
data-toggle="tooltip" title="Send Message"
(click)="openSendMessageModal(single.email)">
<i class="fa fa-envelope" aria-hidden="true"></i>
</button>
</td>
<tr>
</tbody>