Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Angular button redirect

on the following picture you can see my problem. When i click on the letters of the Edit button i get redirected to the page, otherwise if i click the button but not the letters, it wont do anything. enter image description here

this is the code:

`<ng-template #ownerTemplate>
    <button class="edit-btn" mat-raised-button><a routerLink="edit">Edit</a></button>
    <button mat-raised-button (click)="deleteMovie(this.movie!._id)">
      Delete
    </button>
  </ng-template>`

How can i fix it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try putting the routerLink="edit" inside the button and not inside
Like this :

<button class="edit-btn" mat-raised-button routerLink="edit"><a>Edit</a></button>
  <button mat-raised-button >
    Delete
  </button>

You can also remove the <a> if you dont use it

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading