How to apply filters to *ngFor?

前端 未结 23 1246
無奈伤痛
無奈伤痛 2020-11-22 03:44

Apparently, Angular 2 will use pipes instead of filters as in Angular1 in conjunction with ng-for to filter results, although the implementation still seems to be vague, wit

23条回答
  •  孤独总比滥情好
    2020-11-22 04:11

    This is what I implemented without using pipe.

    component.html

    component.ts

    @Component({
    ....
    })
    export class YourComponent {
      filter(itemList: yourItemType[]): yourItemType[] {
        let result: yourItemType[] = [];
        //your filter logic here
        ...
        ...
        return result;
      }
    }
    

提交回复
热议问题