为什么过滤管不起作用?

时间:2017-09-05 17:06:40

标签: angular

我有以下管道过滤器:

@Pipe({name: 'weekByRange'})
export class WeekByRangePipe implements PipeTransform {
  transform(items: Week[], value: number): any {
    return items.filter(function(item: Week) {
      return ( item.group == value);
    });
  }
}

我称之为:

<md-option *ngFor="let item of weeks | weekByRange: newEducationYearModel.range" [value]="item.id">

Weeks对象是:

[ { "id": 6012, "name": "Регулярная", "group": 6010 }, { "id": 6013, "name": "Первая неделя", "group": 6011 }, { "id": 6014, "name": "Вторая неделя", "group": 6011 } ]

newEducationYearModel.range对象是:6011

所以,我没有在md-select列表中获得过滤行。也没有任何错误。

模型是:

public newEducationYearModel: CreateEducationYear;

它被填充如:

public editPeriod(item: Period) {
    this.loadWeeks();
    this.newEducationYearModel.range = 6011;
}

0 个答案:

没有答案