I am using the mat-select-filter library and in the displayMember it is filtering by code only. I want to be able to filter by name and at the same time by code. I am using Angular and Typescript. How can I do it?
<mat-select-filter [placeholder]="'Buscar..'" [array]="estaciones" [displayMember]="'codigo'" (filteredReturn)="filteredEstaciones = $event"></mat-select-filter>
<mat-option *ngFor="let item of filteredEstaciones" [value]="item.id">
{{ item.codigo }} - {{ item.nombre }}
</mat-option>
With Angular's
mat-select-filter, you can change thedisplayMemberproperty to include thecodigoandnombreattributes in order to simultaneously filter by two characteristics. To accomplish this, create a new property in your component and use it as thedisplayMember. This property will mix thecodigoandnombreattributes.combine the
codigoandnombreattributes into a new property that you create in your component:Next, modify your HTML code such that the
displayMemberis the newdisplayNameproperty:mat-select-filternow filters by bothcodigoandnombreattributes simultaneously.