routerLink with query params in Angular html template

Use routerLink and queryParams as inputs to the link as in the following example:

<a class="dropdown-item" [routerLink]="['/my-bookmarks/new']" [queryParams]="{initiator: 'browser'}">
  <i class="fa fa-bookmark"></i>
  Bookmark
</a>

This will generate an url like the following https://www.codever.dev/my-bookmarks/new?initiator=browser

Project: codever - File: navigation.component.html


Shared with from Codever. 👉 Use the Copy to mine functionality to copy this snippet to your own personal collection and easy manage your code snippets.

Codever is open source on Github ⭐🙏

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

How to not select attribute in mongoose schema

How to not select attribute in mongoose schema code snippet Continue reading