Angular 如何通过更改其他下拉列表过滤一个下拉列表
我从angular开始,在我的项目中,我有两个下拉列表,第一个下拉列表:Angular 如何通过更改其他下拉列表过滤一个下拉列表,angular,typescript,Angular,Typescript,我从angular开始,在我的项目中,我有两个下拉列表,第一个下拉列表: <mat-form-field appearance="fill" class = "tp-full-width"> <mat-select #captionlist2 (selectionChange)="filterByCaption($event)"> <mat-op
<mat-form-field appearance="fill" class = "tp-full-width">
<mat-select #captionlist2 (selectionChange)="filterByCaption($event)">
<mat-option *ngFor="let p of list_product.data" [value]="p">
{{ p.description }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class = "tp-full-width">
<mat-select #brandlist (selectionChange)="filterByBrands($event)">
<mat-option *ngFor="let m of list_brands.data" [value]="m">
{{ m.BDesc }}
</mat-option>
</mat-select>
</mat-form-field>
filterByCaption(event: any)
{
console.log(event.value.id);
this.list_brands.filterPredicate =
(data, filter: string) => data.brandcode== event.value.id;
this.list_brands.filter=event.value.id;
}
还可用于onchange标题下拉列表:
<mat-form-field appearance="fill" class = "tp-full-width">
<mat-select #captionlist2 (selectionChange)="filterByCaption($event)">
<mat-option *ngFor="let p of list_product.data" [value]="p">
{{ p.description }}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill" class = "tp-full-width">
<mat-select #brandlist (selectionChange)="filterByBrands($event)">
<mat-option *ngFor="let m of list_brands.data" [value]="m">
{{ m.BDesc }}
</mat-option>
</mat-select>
</mat-form-field>
filterByCaption(event: any)
{
console.log(event.value.id);
this.list_brands.filterPredicate =
(data, filter: string) => data.brandcode== event.value.id;
this.list_brands.filter=event.value.id;
}
但是第二个下拉列表不能通过选择更改第一个下拉列表进行过滤,我该怎么做?它看起来像是
list\u品牌
,list\u产品
的类型如下:
interface YourFilterList<T> {
data: T[];
filterPredicate: (d: T, filter: string) => boolean;
filter: string;
}
只要让管道谁将返回过滤数组,如果选择的东西,如果第一个dd或无,如果第一个是空的