attr.disabled null或空字符串返回true [英] attr.disabled null or empty string is returning true
本文介绍了attr.disabled null或空字符串返回true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果属性具有值,我试图将输入禁用的属性设置为true,但是如果属性为null或空字符串,则我现在使用的内容似乎返回true.
I am trying to set an inputs disabled attribute to true if a property has a value, however what I am using now seems to be returning true if the property is null or an empty string.
[attr.disabled]="userForm.value.email? true: false"
推荐答案
要删除绑定属性,该值必须为 null
而不是 false
To get an bound attribute removed, the value needs to be null
instead of false
[attr.disabled]="userForm.value.email? true: null"
这篇关于attr.disabled null或空字符串返回true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文