Angular routerLink url with parameter in html template

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 ""'>
    <i class="fas fa-tag"></i> Public
  </a>
</div>

This will generate a link similar to the following https://www.codever.land/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.land. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Subscribe to our newsletter for more code resources and news

Adrian Matei (aka adixchen)

Adrian Matei (aka adixchen)
Life force expressing itself as a coding capable human being

Dynamically expand angular material panel when condition met

Dynamically expand angular material panel when condition met code snippet Continue reading

Copy to clipboard with angular material

Published on October 12, 2022