I have a mat-table with a text input to filter it's results.
Datasource is:
[
{
"articolo": {
"code": "22.398.14",
"url": "/url1"
},
"color": "white",
"weight": "10"
},
{
"articolo": {
"code": "22.398.15",
"url": "/url2"
},
"color": "red",
"weight": "20"
}
]
I add this in html:
<mat-form-field>
<mat-label>Filtra</mat-label>
<input matInput (focus)="setupFilter('articolo')" (keyup)="applyFilter($event)" placeholder="Filter">
</mat-form-field>
And in ts:
setupFilter(column: string) {
this.data.filterPredicate = (data, filter) => {
data[column].code.indexOf(filter) != -1;
}
}
applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value;
this.data.filter = filterValue.trim().toLowerCase();
}
But nothing happens
If I add a console.log inside filterPredicate it doesn't fire:
this.data.filterPredicate = (data, filter) => {
console.log(data);
...
What's wrong?
thanks