I made a pipe that works well, but searches only the name. I want to search for more parameters, including: population, region and capital. Check my code:
<div class="card d-flex flex-direction-column"
*ngFor="let country of countries | country:searchTerm; let i=index">
<img [src]="country.flag" alt="flag icon" style="width:100%">
<div class="text-content white">
<h4><b>{{ country.name }} </b></h4>
<div class="d-flex align-items-center">
<p class="unset-margin-p"> Population: </p> <span class="font-w-200">{{ fixNum(country.population) }}</span>
</div>
<div class="d-flex align-items-center">
<p class="unset-margin-p"> Region: </p> <span class="font-w-200"> {{ country.region }} </span>
</div>
<div class="d-flex align-items-center">
<p class="unset-margin-p"> Capital: </p> <span class="font-w-200"> {{ country.capital }} </span>
</div>
</div>
</div>
and most important PIPE
export class CountryPipe implements PipeTransform {
transform(country:any, searchTerm: string): HomeComponent {
if (!country || !searchTerm) {
return country;
}
return country.filter(country =>
country.name.toLowerCase().indexOf(searchTerm.toLowerCase()) !== -1);
}
}