How to use routerLink in Angular to specify value of parameter in url

ama

Adrian Matei

Posted on January 3, 2022

How to use routerLink in Angular to specify value of parameter in url

Project: codever - File: bookmark-list-element.component.html

Use a two-element array when specifying a route parameter:

<div *ngFor="let tag of bookmark.tags" class="btn-group tag-list  mr-2 mt-1"> 
  <a class="dropdown-item"
     [routerLink]="['/tagged', tag]"
     title='Public bookmarks tagged "{{tag}}"'>
    <i class="fas fa-tag"></i> Public
  </a>
</div>
Enter fullscreen mode Exit fullscreen mode

This will generate a link similar to the following https://www.codever.dev/tagged/angular, where the value of the tag parameter in routerLink is the string angular


Reference -

https://angular.io/guide/router


Shared with ❤️ from Codever. 👉 use the copy to mine functionality to add it to your personal snippets collection.

💖 💪 🙅 🚩
ama
Adrian Matei

Posted on January 3, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related