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>
4
  • 2
    Try removing the single quotes from 'items.label' Commented May 7, 2019 at 9:51
  • Thank you, but how can I transfom the value of items.label to put it lowercase ? Commented May 7, 2019 at 10:11
  • 1
    I'd use a "pipe" which can transform each of your items. Take a look at this link. Commented May 7, 2019 at 10:26
  • Sorry , I used it but I writed it wrong . It works now ! Thank you ! Commented May 7, 2019 at 10:47

4 Answers 4

2

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

<li *ngFor = "let items of this.labelsMenu|async">
    <a[routerLink]="[items.label] " href="#" >
</li>
Sign up to request clarification or add additional context in comments.

Comments

1

remove the single quotes

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

Comments

0

Remove the single quotes and href="#"

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

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.