I am trying to add routerLink
to an anchor tag dynamically based on if a routerLink
is passed to the component itself.
This is the code I currently have:
[attr.routerLink]="router ? router : null"
The resulting markup looks like this when a routerLink
is passed, but no href
is passed:
<a _ngcontent-hlo-122="" routerlink="/myRoute">My Link</a>
I've tried this out a number of ways, but I can never seem to get this to work. Does anyone have a solid solution to this problem?