I need to route to a home component when the user clicks a button. I know how to do that using: <a href=””>
, but not using: routerLink
. Is there any way to do that using a button
click
event?
<a class="nav-item nav-link-edit" [routerLink]="['']">home</a>
The code above is how I use an <a href="">
tag to route.
Yes, routerLink
works on both anchor tags and button tags. You can do this:
<button class="nav-item nav-link-edit" [routerLink]="['']">home</button >
routerLink will be working properly.
app.component.html:
<button class="nav-item nav-link-edit" [routerLink]="['Home']">Home</button >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With