Question:
I’m refactoring a directive which adds some sort of a tooltip over the form controls on mouse hover/focus. It’s simple to use. Just add it to the element and define its text. The input you use for the text also defines the tooltip’s styling[libError]
value with non-empty string.Answer:
Yes, it is possible, but then you need to turn yourlibError
property into a boolean instead.
For a better overview, check out boolean property coercion (this is how the CDK does it).For an usage example, we can take a look at the
mat-divider
. It uses boolean coercion to allow us to write something as simple as this:If you have better answer, please add a comment about this, thank you!