Working on an Angular 9 app where data is displayed using a mat-table and filtered based on certain fields. The issue I'm facing is that the dropdown menu shows duplicate values, which is expected since some values may be repeated in the dataset. The data displayed is from a mat-table dataSource.filteredData, so using new Set() or similar methods is not an option. How can I modify my code to show only unique values in the dropdown?
Here is a snippet of my code:
<mat-form-field appearance="fill">
<mat-label>Select an option</mat-label>
<mat-select>
<mat-option *ngFor="let country of dataSource.filteredData">{{country.name}}</mat-option>
</mat-select>
</mat-form-field>
...
<table>
...
</table>
Note: I attempted to create a Pipe for uniqueness, but it only works effectively for static Arrays, and my Array changes with each filter. Any suggestions on how to tackle this issue? Thank you for your assistance 😊