Is it possible to bind a [routerLink] to a div? Angular 2+

Viewed 23001

I am new to Angular and I have found no clear answers on this subject no matter what I search for.

This is currently working:

<div class="col-sm" (click)="brandListRoute()">

which directs to this function in my component:

brandListRoute() {
        this.router.navigate(['explore/brands']);
}

So this works perfectly, however when I first tried binding [routerLink] like this:

<div [routerLink]="['explore/brands']">  </div>

I can click on the div but nothing happens. So my question is, does a [routerLink] only work on things like anchor tags and buttons or is my above logic flawed?

Need to find the best solution for my problem. Thanks so much in advance!

1 Answers

Yes it can be attached to div tag, your route is probably wrong try add / in front of route.

<div [routerLink]="['/explore/brands']"> go to this location </div>
Related