IHAVE一個問題,我想她的類別進行過濾我的組件的列表,但我管不工作,你能不能幫我管角2過濾器組件通過枚舉
,這是我的菸斗:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'matchCategory'
})
export class MatchesCategoryPipe implements PipeTransform {
transform(items: Array<any>, category: string): Array<any> {
return items.filter(item => item.category === category);
}
}
<!-- list of category!-->
export enum ComponentCategory {
FormControls = <any> 'Form Controls',
Containers = <any> 'Containers' ,
Boxes = <any> 'Boxes',
DataPresentation = <any> 'Data Presentation',
Layout = <any> 'Layout',
Miscellaneous = <any> 'Miscellaneous',
All = <any> 'All'
}
<tr *ngFor="let c of componentDescriptorsList | matchCategory: c.category" [ngValue]="'Form Controls'">
<!--<tr *ngFor="let c of componentDescriptorsList">-->
<td><a href="#/components/{{c.selector}}">{{c.title}}</a></td>
<td><{{c.selector}}></td>
<td>{{c.description}}</td>
<td>{{c.category}}</td>
我的組件列表中有一類,我想以顯示爲例只是分量誰categoryis「表單控件」
感謝
管道基本的例子有你註冊的管道中app.module.ts –
沒有我不但現在我已經寫在app.module中,並且我有一個新的錯誤 – ouanounou
我發佈錯誤日誌anwser – ouanounou