I have dynamic table tr
and each row contains a submit button. I also applied input
control name dynamically. What is the best way to enable/ disable button based on the tr
row validation?
<form #form1="ngForm">
<table>
<thead><tr><th>Name</th><th>Email</th><th>Action</th></tr></thead>
<tbody>
<tr *ngFor="let value of data; let i=index">
<td><input type="text" name="name{{i}}" #nameInput="ngModel" [(ngModel)]="dataModel.name" [value]="value.name" required /></td>
<td><input type="text" name="email{{i}}" #emailInput="ngModel" [(ngModel)]="dataModel.email" [value]="value.email" required /></td>
<td><button type="submit" [disabled]="form1.form.invalid">Submit</button></td>
</tr>
</tbody>
</table>
</form>
Here, above [disabled]
condition applies for all rows but i want to apply it based on the each row.
<tr></tr>
with a<form>
tag. – Anuradha Gunasekara