typescript - How to exclude white spaces while search -


in angular2+ wrote pipe searching through array, working fine. want exclude white spaces in array.

my current pipe

import { pipe, pipetransform } '@angular/core';  @pipe({   name: 'arraysearch' })  export class arraysearchpipe implements pipetransform {    transform(value: any, args?: any): {     if (!args) { return value; }     return value.filter(item => this.checkvalues(item, args));   }    checkvalues(item, args) {     const value = object.keys(item).map(k => item[k]);     return string(value).indexof(args) > -1;   }  } 

this piece of code searches terms exact terms. how exclude spaces in array items , search?

thanks.

try following:

checkvalues(item, args) {     const value = object.keys(item).map(k => item[k]);     return string(value).replace(/ /g,"").indexof(args) > -1;  } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -