我自定义了材质表过滤器。但我无法消除特殊字符。像这样“,”
/////创建了一个这样的界面./////
export interface Element {
name: string;
position: number;
weight: number;
symbol: string;
}
//////////filter function like this////
applyFilter(filterValue: string) {
filterValue = filterValue.trim(); // Remove whitespace
filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches
this.dataSource.filter = filterValue;
}
////////filter predicte like this to convert the data/////
this.dataSource = new MatTableDataSource(data['products']);
this.dataSource.filterPredicate =
(data: Element, filter: string) => data.name.indexOf(filter) != -1;