I need help with creating an HTML table that includes a cell with a button and a dropdown generated using ngFor. How can I disable the buttons (generated via ngFor) if no value is selected from the dropdown? Here's what I have tried so far:
In my AppComponent, I have the following:
ts
customers: Array<Object> = [];
level: string;
changedvalue(event: Event) {
const value = (<HTMLSelectElement>event.target).value;
this.level = value;
}
html
<tbody>
<tr *ngFor="let customer of customers">
<td> {{ customer.uid }} </td>
<td> {{ customer.name }} </td>
<td> {{ customer.level }}</td>
<td>
<select (change)="changedvalue($event)" class="form-control" name="level">
<option hidden selected> -- select an option -- </option>
<option>Level 1</option>
<option>Level 2</option>
</select>
</td>
<td><button [disabled]=!level >Send</button></td>
</tr>
</tbody>
The issue with this code is that it enables all the buttons if any dropdown has a selected value. What I want is to only enable the button in front of each individual dropdown. How can I connect each button to its respective dropdown created using ngFor?