Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. filter() {
  2.     this.empleadosQuery.empleados$.subscribe(value => this.dataSource = value);
  3.     this.dataSource = this.dataSource.filter((empleado) => this.checkFilter(empleado));
  4.   }
  5.  
  6.   checkFilter(empleado) {
  7.     this.formatFilter(empleado);
  8.  
  9.     for (let i = 0; i > this.empleadoFormated.length; i++) {
  10.       if (this.empleadoFormated[i].includes(this.search)) {
  11.         return true;
  12.       } else {
  13.         return false;
  14.       }
  15.     }
  16.   }
  17.  
  18.   formatFilter(empleado) {
  19.     this.search = this.replaceCharacters(this.search);
  20.     this.empleadoFormated = this.termsOfSearch.map( term => this.replaceCharacters(empleado[term]));
  21.   }
  22.  
  23.   replaceCharacters(value) {
  24.     if (value) {
  25.       return value.trim().toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
  26.     }
  27.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement