Simple filter in ionic / angular

03:17:00 0 Comments



/// first create duplicate temp variable of variable used in the forloop


onSearch(evt: any) {
        console.log(evt.target.value);
        const val = evt.target.value;
        this.usersList = [];
   
        const temp = this.tempUsers.filter(function(d) {
      return String(d.ecn).toLowerCase().indexOf(val) !== -1 ||
      d.fullname.toLowerCase().indexOf(val) !== -1 ||
      d.gender.toLowerCase() === val ||
      d.department.toLowerCase().indexOf(val) !== -1 ||
      String(d.doj).toLowerCase().indexOf(val) !== -1 || !val;
    });

    // update the rows
    this.usersList = temp;
    }

0 comments: