我试图将ngFor项作为参数传递给管道但是出错:
异常:调用节点模块失败,错误:错误:模板 解析错误:TypeError:无法读取属性'toUpperCase' undefined(“{{name}} ng-container [ERROR - >] * ngFor =”让评级为 评级| 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);
}
}
答案 0 :(得分:2)
从{{}}
{{name}}
{{}}
从不与(event)="..."
[prop]="..."
或*someDirective="..."