0
我想實現包含對象的對象的搜索。 我想使用角度搜索過濾器來過濾Property_id參數。我如何才能在「property_id」對象上應用搜索過濾器。Angular 2從包含另一個對象的對象中搜索管道過濾器?
我想實現包含對象的對象的搜索。 我想使用角度搜索過濾器來過濾Property_id參數。我如何才能在「property_id」對象上應用搜索過濾器。Angular 2從包含另一個對象的對象中搜索管道過濾器?
如下您可以創建一個管道,
@Pipe({name: 'filterByPropertyId'})
export class FilterByPropertyId implements PipeTransform {
transform(yourList: yourObject[], property_id: string): any[] {
if (yourList) {
return yourList.filter((yourList: yourObject) => list.property_id === property_id);
}
}
}
,並在組件級
<div *ngFor="let r of yourList| FilterByPropertyId:propertyId">
</div>