I'm getting an error as follows:
Cannot read property 'filter' of undefined.
Component template:
<input #input placeholder="Search" id="search">
<div class="item" *ngFor="let item of data | searchPipe: input.value">
{{item}}
</div>
Pipe code:
@Pipe({
name: 'searchPipe',
pure: false
})
export class SearchPipe implements PipeTransform {
transform(data: any[], searchTerm: string): any[] {
searchTerm = searchTerm.toUpperCase();
return data.filter(item => {
return item.toUpperCase().indexOf(searchTerm) !== -1
});
}
}
What causes the error?