Reputation: 1897
Is it possible to bind a boolean variable to the existence of a attribute?
template: ...,
host: {
"[attr.disabled]": "disabled"
}
This is rendered in the element as disabled="true" or disabled="false". But I want to use it in css with the [disabled] selector, that if the variable is false, the attribute doesn't exist and if true it does exist. Thanks in advance.
Upvotes: 5
Views: 2273
Reputation: 657536
For a boolean attribute to be removed the value needs to be null
not false
"[attr.disabled]": "disabled ? true : null"
Upvotes: 9