I have a link and would like to add the rel=nofollow only on specific link.
rel=nofollow
It is possible to do that with Angular?
2
[rel]="i ? 'nofollow' : null
Basically, When using the null value, the tag will just be ignored.
null
Can you please try like this
<a [attr.rel]="addNofollowAttribute ? 'nofollow' : null" href="https://example.com">Your Link</a>
In this example, [attr.rel] binds the rel attribute to the value 'nofollow' when addNofollowAttribute is true, and it binds it to null (which effectively removes the rel attribute) when addNofollowAttribute is false.
[attr.rel]
rel
'nofollow'
addNofollowAttribute
true
false
Click here to cancel reply.
2
Answers
TLDR
[rel]="i ? 'nofollow' : null
Why
Basically, When using the
null
value, the tag will just be ignored.Can you please try like this
In this example,
[attr.rel]
binds therel
attribute to the value'nofollow'
whenaddNofollowAttribute
istrue
, and it binds it tonull
(which effectively removes therel
attribute) whenaddNofollowAttribute
isfalse
.