简体   繁体   English

Angular2 - 将 ngFor 项目作为参数传递到管道中?

[英]Angular2 - passing ngFor item into a pipe as a parameter?

Im trying to pass an ngFor item into a pipe as a paramter but get an error:我试图将一个 ngFor 项目作为参数传递到管道中,但出现错误:

Exception: Call to Node module failed with error: Error: Template parse errors: TypeError: Cannot read property 'toUpperCase' of undefined ("{{name}} ng-container [ERROR ->]*ngFor="let rating of ratings | groupFilter:{{name}} "异常:调用节点模块失败并出现错误:错误:模板解析错误:类型错误:无法读取未定义的属性“toUpperCase”(“{{name}} ng-container [ERROR ->]*ngFor="let rating of ratings | groupFilter:{{name}} "

This is the html:这是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>

and this is my pipe:这是我的烟斗:

    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);
    }
}

remove {{}} from {{name}}{{name}}删除{{}} {{name}}

{{}} never goes together with (event)="..." [prop]="..." or *someDirective="..." {{}}永远不会(event)="..." [prop]="..."*someDirective="..."

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM