RouterLink with multiple params in Angular
34,126
Yes, of-course, you could use routerLink
to form href
tag dynamically for navigation. Values in array where each value will get evaluated against Component context.
[routerLink]="['/category', category, page ]"
Author by
Dawid Zbiński
Last couple of years I've been working mostly as a Full-Stack Web Developer. I'm obsessed with performance and good-looking code.
Updated on July 05, 2022Comments
-
Dawid Zbiński almost 2 years
I want to create a link to the route with multiple parameters and bind them in tempalte. Until now, I've been doing this by executing the function on
(click)
event, but I was wondering if it's possible withinRouterLink
's binding.Here is the function I use to bind parameters:
redirect() { this._router.navigate( ['/category', { cat: this.category, page: this.page }]); }
My route looks like:
{ path: 'category/:cat/:page', component: PostComponent }
Will I be able to do the same inside
routerLink
directive?