routerLink with params is not working
<a routerLink="/post?id=1">
Link
</a>
I want to navigate in other links with params using routerLink
CodePudding user response:
Use [queryParams]
in adition to routerLink
as explained in this post How to pass query parameters with a routerLink
CodePudding user response:
you should use
<a [routerLink]="['/post']" [queryParams]="{ id: 1 }">View post</a>
CodePudding user response:
In your particular example you'd do the following routerLink:
<a [routerLink]="['/post']" [queryParams]="{id: '1'}" queryParamsHandling="preserve"> Link
</a>
id can be variable as well.