I have a table and would like to dynamically add a row to that table. Below is my code!
<tr *ngIf="customer">
<td>4</td>
<td>
<input type="text" name="firstName" required minlength="2">
</td>
<td>
<input type="text" name="lastName" required minlength="2">
</td>
<td>
<input type="text" name="countryCode" required maxlength="2">
</td>
<td>
<input type="number" name="age" required minlength="2">
</td>
<td>
<i class="fas fa-times" (click)="cancel()"></i>
</td>
<td>
<i class="far fa-save" (click)="save()"></i>
</td>
</tr>
Below the table the above row should be added to. is the selector which holds the above html(the single table row to be added). Currently, when the button is clicked, the above row appears at the very bottom of the page instead of being added to the table as intended.
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Country</th>
<th scope="col">Gender</th>
<th scope="col">Age</th>
<th scope="col">Edit</th>
<th scope="col">Delete</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let customer of customerArray; let i = index">
<td>{{i + 1}}</td>
<td>{{customer.firstName}}</td>
<td>{{customer.lastName}}</td>
<td>{{customer.countryCode}}</td>
<td>{{customer.gender}}</td>
<td>{{customer.age}}</td>
<td><i class="fas fa-edit" (click)="editCustomer()"></i></td>
<td><i class="fas fa-trash-alt" (click)="deleteCustomer(customer)"></i></td>
</tr>
<add-edit-customer></add-edit-customer>
</tbody>
</table>