Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 对于,将多参数函数传递给管道_Angular_Function_Pipe_Parameter Passing - Fatal编程技术网

Angular 对于,将多参数函数传递给管道

Angular 对于,将多参数函数传递给管道,angular,function,pipe,parameter-passing,Angular,Function,Pipe,Parameter Passing,我正在使用此链接的“where”管道: 可与以下功能一起使用: const values = [{ a: 1, c: { d: 3, e: { f: 4 } } }, { a: 2, c: { d: 4, e: { f: 5 } } }]; const numbers = [1, 2, 3, 4, 1,

我正在使用此链接的“where”管道:

可与以下功能一起使用:

const values = [{
    a: 1,
    c: {
        d: 3,
        e: {
            f: 4
        }
    }
}, {
    a: 2,
    c: {
        d: 4,
        e: {
            f: 5
        }
    }
}];

const numbers = [1, 2, 3, 4, 1, 4];

// ...

aEqualsOne(item) {
    return item.a === 1;
}

//usage example :
{{ values | where: aEqualsOne }} <!-- [{ a: 1, c: { d: 3, e: { f: 4 } }] -->
但我必须修改函数以接受另一个参数:

checkNum(num, k) {
    console.log(num + " > " + k + "?");
    return num > k;
}
问题是我找不到方法将列表项和“k”传递给传递给管道的函数:

我试过:

<card  *ngFor="let num of listOfNum | where: checkNum(k)></card>

<card  *ngFor="let num of listOfNum | where: checkNum(num, k)></card>

但是现在还没有成功

我该怎么办?

修改:

<card  *ngFor="let num of listOfNum | where: checkNum(k)></card>

不工作:(从函数checkNum的日志来看,'k'值似乎是某种索引(从0到列表长度)“我必须修改函数以接受另一个参数”,或者您创建一个从其他地方获取该值的函数。
<card  *ngFor="let num of listOfNum | where: checkNum(k)></card>

<card  *ngFor="let num of listOfNum | where: checkNum(num, k)></card>
<card  *ngFor="let num of listOfNum | where: checkNum(k)></card>
<card  *ngFor="let num of listOfNum | where: checkNum : k></card>