【发布时间】:2017-02-23 14:10:03
【问题描述】:
我试图将 ngFor 项目作为参数传递到管道中,但出现错误:
异常:调用节点模块失败并出现错误:错误:模板 解析错误:TypeError:无法读取属性“toUpperCase” undefined ("{{name}} ng-container [ERROR ->]*ngFor="let rating of 收视率 | groupFilter:{{name}} "
这是html:
<tr *ngFor="let name of measureNames">
<td>{{name}}</td>
<td><input class="form-control"></td>
<ng-container *ngFor="let rating of ratings | groupFilter:{{name}} ">
<ng-container *ngFor="let key of rating | keys">
<td *ngIf="key=='measureRating'"><input class="form-control" value={{rating[key]}}></td>
</ng-container>
</ng-container>
</tr>
这是我的管道:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'groupFilter',
pure: false
})
export class GroupFilterPipe implements PipeTransform {
transform(items: any[], args: string): any {
console.log("Filter ARGS: " + args);
return items.filter(item => item.measureName==args);
}
}
【问题讨论】:
-
试试
*ngFor="let rating of ratings | groupFilter:name"。在name附近没有{{ }}。
标签: angular parameters pipe ngfor