<input id="name" type="text" [(ngModel)]="searchText" />
<div *ngFor="let item of data | filter : searchText">
<p>{{ item.name }} {{item.lastname}}</p>
<p>Возраст: {{ item.age }}</p>
</div>
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'filter'
})
export class FilterPipe implements PipeTransform {
transform(items: any[], searchText: string): any[] {
if(!items) return [];
if(!searchText) return items;
searchText = searchText.toLowerCase();
return items.filter( it => {
return it.name.toLowerCase().includes(searchText);
});
}
}