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