I would like to conditionally apply a title attribute to an element, which I am attempting like so:
<div class="option-title" [attr.title]="isTitleTruncated() ? option.title : null">
{{option.title}}
</div>
But I would like to pass in the element reference to my function being used on the condition, but have been unable to do so. I tried using this and that gives me the component instance, but I want the actual div itself. Is this possible?
Try using template reference variable like:
<div ... #divRef [attr.title]="isTitleTruncated(divRef) ? option.title : null">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With