1st. : Yes.
2nd. : you must import pipeinside yours componentand call .transform()on the button (click).
import { FilterByPipe } from 'ngx-pipes/src/app/pipes/array/filter-by';
@Component({
providers: [FilterByPipe]
})
export class AppComponent {
filteredArr: any[];
constructor(private readonly filterByPipe: FilterByPipe) {
this.filteredArr = this.users.slice();
}
onClickBtn() {
this.filteredArr = this.filterByPipe.transform(
this.users,
'work.company',
this.currentCategory
);
}
}
Remember to change the original array in template, you should use:
*ngFor="let <variable> of filteredArr"...
source
share