Angular routerLink relative navigation without matrix parameters


When I navigate to a child component via routerLink directive, the parent component matrix parameters are kept in the url. For example, if the url is localhost/parent;arg=1, and the routerLink looks like:

<a routerLink="child"></a>

The child url will be localhost/parent;arg=1/child, but I want to leave out matrix parameters while navigation. How can I do it?


As I found in routerLink description, you can just add an empty matrix parameters {} to beginning of the route. Because, in my case, the route doesn’t have a prefix (which means that the route starts from the current activated route), the parent parameters will be replaced by empty ones.

<a [routerLink]="[{}, 'child']"></a>

Answered By – Valeriy Katkov

Answer Checked By – Katrina (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.