Angular 4 Filter Search Custom Pipe

后端 未结 6 1870
清歌不尽
清歌不尽 2020-11-28 15:14

So I am trying to build a custom pipe to do a search filter of multiple values in a ngFor loop. I have looked for a number of hours for a good working example, and most of t

6条回答
  •  一生所求
    2020-11-28 15:34

    You can use the given function instead on the (input) event of your input box

    filterNames(event)
    {
     this.names_list = this.names_list.filter(function(tag) {
     return tag.name.toLowerCase().indexOf(event.target.value.toLowerCase()) >= 0;
     });
    }
    

    Hope it helps..

提交回复
热议问题