EXCEPTION: Root segment cannot have matrix parameters

angular

Solution

Recently, it is done this way in Angular 5+:

`<a [routerLink]="['/']" [queryParams]="{ 'tour': true }"> text </a> `

Doing `[routerLink]="['/', { 'tour': true' }]"> text </a>` would throw the error

Problem

Html: ``` [routerLink]="['', {'scrollTo': '#contact'}]" ``` TS: ``` this.route.params.forEach((params: Params) => { if (params['scrollTo']) { // some code here } }); ``` Error: EXCEPTION: Root segment cannot have matrix parameters I can't have 'scrollTo' param in my routerLink? It clearly appears on the angular 2 documentation: https://angular.io/docs/ts/latest/guide/router.html#!#appendix-link-parameters-array EDIT: Doesn't seem to complaint with : `<a [routerLink]="['/crisis-center', { scrollTo: '#contact' }]">Crisis Center</a>`. But I need it with my '' root route.

Original source