Having trouble overriding the filterPredicate in my table with phone numbers and states. The filtering is working, but there's a bug where results for "UNASSIGNED" show up when I filter for "ASSIGNED". Can someone assist me with the correct syntax for overwriting the filterPredicate?
https://i.sstatic.net/wOWtB.png
Here's a snippet of the HTML:
<table mat-table [dataSource]="dataSource">
<ng-container matColumnDef="telefonnummer">
<th mat-header-cell *matHeaderCellDef> Telefonnummer </th>
<td mat-cell *matCellDef="let element"> {{element.areaCode.prefix}}-{{element.areaCode.base}}-
{{element.extension}} </td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef> Status </th>
<td mat-cell *matCellDef="let element"> {{element.phoneNumberType}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
And a part of the TypeScript class:
displayedColumns: string[] = ['telefonnummer', 'status'];
products = [];
dataSource = new MatTableDataSource<any>(this.products);
constructor(private httpClient: HttpClient) {
this.getAllNumbers();
}
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
ngOnInit() {
this.dataSource.paginator = this.paginator;
this.dataSource.filterPredicate = (data: any, filter: string) => {
let matchFound = false;
if (data === filter) {
matchFound = true;
}
return matchFound;
};
}
If anyone can offer guidance, it would be greatly appreciated!