如何在组件代码中引用模板中的管道

时间:2017-04-06 09:59:02

标签: angular angular2-template angular-pipe

如何在组件代码中引用模板中的管道? 在模板中

 <tr *ngFor="let score of scores
                        | filterScores:modelFilter.value:modelFilter.name">

我想从组件中的自定义管道中检索值,以便我可以在代码中使用它们。 如果我在构造函数中添加管道,我将创建新管道。

constructor(private filterScoresPipe: FilterScoresPipe) {
}

1 个答案:

答案 0 :(得分:0)

使用Pipe的实例调用transform方法。

let filterScoresPipe = new FilterScoresPipe();
filterScoresPipe.transform(input, agr1, arg2);
相关问题