1

i want to ask if there is a way for do this

<button *ngFor="let link of links" routerLink="{{link.value}} <<<<  (i want to insert value from array to this
">{{link.Name}}</paper-button>

links = [
{Name:'Menu1' , value:'/Menu1'},
{Name:'Menu2' , value:'/Menu2'},
]

and in my router-module,

{ path: 'Menu1',  component: Menu1Component },
{ path: 'Menu2',  component: Menu2Component },
Rommy
  • 447
  • 3
  • 10
  • 23

1 Answers1

1

By using the notation [routerLink] instead of routerLink, you can pass instance properties to the value. In your case it would be:

<button *ngFor="let link of links" [routerLink]="link.value">
    {{link.Name}}
</paper-button>
Bertofer
  • 770
  • 6
  • 18