我在ts中使用了这段代码
export type pieChartOptionss = {
series?: ApexNonAxisChartSeries | '';
chart?: ApexChart | '';
legend?: ApexLegend | '';
dataLabels?: ApexDataLabels | '';
responsive?: ApexResponsive[] | '';
labels?: any | '';
};
export class DashboardComponent implements OnInit {
public pieChartOptionss!: Partial<pieChartOptionss>;
}
(response: any) => {
this.user_data = response.results;
console.log('user_data', this.user_data)
this.user_data_true = this.user_data.filter(x => x.is_active === true)
this.user_data_false = this.user_data.filter(x => x.is_active === false)
this.pieChartData = [this.user_data_true.length, this.user_data_false.length];
this.pieChartOptionss = {
series: [this.user_data_true.length, this.user_data_false.length],
chart: {
type: 'donut',
width: 270, …
Run Code Online (Sandbox Code Playgroud) 我想为自动完成素材创建过滤器.
我的模特:
export class Country {
country_id: number;
name: string;
}
Run Code Online (Sandbox Code Playgroud)
打电话给webmethod ws
this.ws.AllCountry().subscribe(
countryes => {
this.countryes = countryes.map((country) => {
return new Country(country);
});
}
);
Run Code Online (Sandbox Code Playgroud)
创建此过滤器,但不起作用:
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;
}
Run Code Online (Sandbox Code Playgroud)
你能告诉我任何解决方案吗?
谢谢