angularhttp-put

How to add routerlink with string interpolation in angular


I need to add

    router= "/update/id" in my code, where "id" has to be rendered dynamically based on values by *ngFor directive. (i.e) {{obj.id}}.So that id gets rendered dynamically

How to do this?


Solution

  • You can either use String Interpolation

    routerLink="/update/{{obj.id}}"
    

    or Attribute Binding Syntax:

    [routerLink]="'/update/' + obj.id"
    

    or as Pankaj suggested, Attribute Binding Syntax like this:

    [routerLink]="['/update', obj.id]"