如何在RouterLink中将管道应用于值? [英] How to apply pipe to value in RouterLink?
本文介绍了如何在RouterLink中将管道应用于值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Angular 7中,我的路线如下:
I have the following route in Angular 7:
<a [routerLink]="['/categories', {{ category.name | slugify }}, category.id]">{{category.name}}</a>
问题在于在 routerlink
中应用管道 slugify
.
The problem is with applying the pipe slugify
within the routerlink
.
如何将管道应用于 routerLink
中的值?
How can I apply a pipe to a value inside routerLink
?
推荐答案
尝试删除像这样的大括号:
Try removing the curly brackets like this:
< a [routerLink] ="['/categories',category.name | slugify,category.id]"> {{category.name}}</a>
您在那里不需要它们,因为您使用的是已经在评估TypeScript代码的属性绑定.
You don't need them there because you are using property binding which is already evaluating to TypeScript code.
这篇关于如何在RouterLink中将管道应用于值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文