I want to be able to search though the categories
array by performing a search on the category name. I tried the following solution, but I'm not sure how to edit the variables in the pipe to fit my need.
With the following code, console logs the following error.
categories.component.html:46:10 caused by: item.indexOf is not a function
Template
<tr *ngFor="let category of categories | textFilter:filterText">
<td>{{category.name}}</td>
<td>{{category.slug}}</td>
</tr>
Pipe
@Pipe({ name: 'textFilter' })
export class TextFilterPipe
{
transform(value: any, term: any) {
if (!term) return value;
return value.filter((item: any) => item.indexOf(term) > -1);
}
}