2

I want to make a dynamic routing into my template. Values of routing come from an array which is iterated with ngFor. Also I want to make some transformations to this values which are of type string. Thanks

I tried to put values from an array but it gives me this error : Error: Cannot match any routes. URL Segment: 'items.label' Error: Cannot match any routes. URL Segment: 'items.label'

<li *ngFor = "let items of this.labelsMenu|async">
    <a[routerLink]="['items.label'] " href="#" >
</li>
N.Y
  • 185
  • 1
  • 9

4 Answers4

2

It should be without the quotes in 'items.label'

<li *ngFor = "let items of this.labelsMenu|async">
    <a[routerLink]="[items.label] " href="#" >
</li>
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
1

remove the single quotes

 <li *ngFor = "let items of this.labelsMenu|async">
        <a[routerLink]="[items.label]" href="#" >
    </li>
0

Remove the single quotes and href="#"

<li *ngFor = "let items of this.labelsMenu|async">
    <a [routerLink]="['items.label']">
</li>
Krishna Rathore
  • 9,389
  • 5
  • 24
  • 48
0

You just need to remove single quotationsand href='#'. Hope you wanted to put href because of hover mouse pointer. For that you can add a style in your tag as given style="cursor: pointer".

<li *ngFor = "let items of this.labelsMenu|async">
    <a[routerLink]="[items.label]" style="cursor: pointer">
</li>
Denuka
  • 1,142
  • 3
  • 13
  • 21