CodeHip
CodeHip

Reputation: 377

Routerlink works without anchor tag

I just noticed that routerLink works on any element e.g on divs, mat-card, mat-title, etc, without needing to wrap an anchor tag around.

Is that okay / safe to do so or you need to use it with the anchor ? Maybe it can have some bad consequences later if doing so ?

Upvotes: 6

Views: 2084

Answers (1)

ForestG
ForestG

Reputation: 18123

I think routerLink.navigate is a direcitve which listens on an onclick event.

So as long as using onClick is safe, you are safe to use routerLink too.

Upvotes: 5

Related Questions