2017-10-20 68 views

回答

0

如下您可以創建一個管道,

@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> 
相關問題