DEV Community

Cover image for How to use routerLink in Angular to specify value of parameter in url
Adrian Matei for Codever

Posted on • Edited on • Originally published at codever.dev

3 2

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay