In Angular material official website Angular Material Table it is mentioned that filterPredicate: ((data: T, filter: string) => boolean) will filter data based on a specific field. But don't know how to start. Is there any example is present for this.
Asked
Active
Viewed 1.4k times
1 Answers
15
This answer seems to show how to use the filter predicate:
https://stackoverflow.com/a/50174938/6130716
It works like so:
this.dataSource.filterPredicate = (data: MyObject, filter: string) => {
return data.property == filter;
};
this.dataSource.filter = myValue;

Pete
- 769
- 7
- 20
-
Thanks, @peter for the response it's working correctly. – Tanvi Shah Apr 20 '18 at 07:18
-
would you do this in ngOnInit? – umutesen May 30 '18 at 13:30