【发布时间】:2018-07-17 20:19:24
【问题描述】:
我想为自动完成材料创建过滤器。
我的模特:
export class Country {
country_id: number;
name: string;
}
调用 webmethod ws
this.ws.AllCountry().subscribe(
countryes => {
this.countryes = countryes.map((country) => {
return new Country(country);
});
}
);
创建此过滤器,但不起作用:
filterStates(val: string) {
if (val) {
let filterValue = val.toLowerCase();//toLowerCase does not exist on type Country.
return this.countryes.filter(name => name.toLowerCase().startsWith(filterValue));
}
return this.countryes;
}
您能建议我任何解决方案吗?
谢谢
【问题讨论】:
-
你怎么打电话给
filterStates?
标签: angular typescript filter autocomplete angular-material