I am currently working on creating a filter for autocomplete material.
Here is an example of my model:
export class Country {
country_id: number;
name: string;
}
When calling the web method ws:
this.ws.AllCountry().subscribe(
countries => {
this.countries = countries.map((country) => {
return new Country(country);
});
}
);
I have tried to create the filter, but unfortunately, it is not functioning as expected:
filterStates(val: string) {
if (val) {
let filterValue = val.toLowerCase();
return this.countries.filter(name => name.toLowerCase().startsWith(filterValue));
}
return this.countries;
}
If anyone has any suggestions or solutions, I would greatly appreciate it. Thank you!