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
Post a Comment