I want to create an array of objects and use this array into a table. The array will receive data from a list and some check boxes. The main problem is that if the user will select another product from a list the table will just add the new product from that array but the old product will remain in the table.
products = [
{code: '123', name: 'product1'},
{code: '321', name: 'product2}'
]
<select formControlName="modelPDC" (click)="selectProduct()">
<option *ngFor="let prod of this.products"
[value]="prod.code">{{ prod.name }}</option>
</select>
<tr>
<td>{{ productSelected.name }}</td>
<td>{{ productSelected.code }}</td>
</tr>
//I will use *ngFor to populate the table.
//The productSelected will be the array filled with the data selected in
//the list and others check boxes.
I know how to fill the array, I will use the .push method but I don't know how to avoid duplicates field in the table (array -> productSelected). I was thinking to search into the array and if the product was selected just to remove it, or something like that.
I hope I war clearly enough.. Thank you!