I enter a string in the filter and filter by name in the table. The code is working!
<input type="text" name="searchString" [(ngModel)]="searchString" /> <table> <tr *ngFor="let client of clients | filter: searchString"> <td>{{client.id}}</td> <td>{{client.name}}</td> <td>{{client.surname}}</td> <td>{{client.city}}</td> <td>{{client.street}}</td> <td>{{client.housenumber}}</td> <td>{{client.apartment}}</td> <td ><ul *ngFor='let phone of client.phones'>{{phone.phoneNumber}}</ul><br /></td> <td><button type="button" (click)="loadTask(client.id)">View Task</button></td> </tr> The code in pipe is:
export class FilterPipe implements PipeTransform { transform(clients: any[], searchString: any): any { console.log('searchString', searchString); return searchString ? clients.filter(client => client.name.toLowerCase().indexOf(searchString) !== -1) : clients; }; } How to change pipe to filter by two columns? For example, by name and surname
FilterPipe? - Stepan Kasyanenko