我正在尝试在循环中将参数传递给我的 routerLink 。下面是对象数组的样子:
这是带有 routerLink 链接的循环:
<li *ngFor="let Achievement of AllAchievements">
example from multiple sources
does not work with a variable 'x'. Outputs the letter x
<a routerLink="page" [queryParams]="{x : 1}">anchor text</a>
example from multiple sources
link is outputted /%5B'page',%20%7BAchievement.type%20:%20'hello'%7D%20%5D'
<a routerLink="['page', {Achievement.type : 'hello'} ]">anchor text</a>
outputs long/encoded string as param value
<a [routerLink]="['page']" queryParams="{ [Achievement.type] : 'hello' }">anchor text</a>
</li>
期望的输出:<a href="page?position=hello"></a>