Let’s say we have a link and we want to open it in either new tab or same tab, depending on the value of a variable.
Let’s assume openInNewTab variable is false:
[attr.target]="openInNewTab ? '_blank' : null"- works fine, produces notargetattribute[target]="openInNewTab ? '_blank' : null"- producestarget="null"as an attribute, which still opens the link in a new tab, just the same as if you used_blank
TL;DR: use [attr.target] for best results :)
Top comments (0)