我有以下管道过滤器:
@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;
}