Advertisement
attilan

Search by name

Nov 18th, 2021
2,556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export const selectToolsByNameSearch = (searchExpression: string) =>
  2.   createSelector(selectTools, (tools) => {
  3.     return tools.filter((tool) =>
  4.       tool.name.toLocaleLowerCase().includes((searchExpression || '').toLocaleLowerCase())
  5.     );
  6.   });
  7.  
  8. this.tableService.search$
  9.       .pipe(
  10.         switchMap((expression: string) =>
  11.           this.store.pipe(select(selectToolsByNameSearch(expression)))
  12.         )
  13.       )
  14.       .subscribe((data) => (this.dataSource.data = data));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement