我有这个课:

    export class Tache {
       id: number;
       text: string;
       stat: number;
}

Stat可以等于0,1或2。

当stat = 0时我会打印taches,我尝试使用过滤器
<md-list *ngFor="let tache of taches | filter : 'tache.stat' : '0'"  (click)="onSelect(tache)" [class.selectionnee]="tache === tacheSelectionnee">

但是我得到这个错误:
zone.js:569 Unhandled Promise rejection: Template parse errors:
The pipe 'filter' could not be found ("

最佳答案

您不需要过滤器。通过包装模板来打破逻辑。将ng-template用于Angular 4。

   <template *ngFor="let tache of taches">
     <md-list *ngIf="tache.stat==0"
           (click)="onSelect(tache)"
           [class.selectionnee]="tache === tacheSelectionnee">
     </md-list>
   </template>

08-06 18:33