Angular 5:验证禁用的字段 [英] Angular 5: Validating disabled fields
本文介绍了Angular 5:验证禁用的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找到了这篇文章 但它不能解决我的问题.我无法验证禁用 FormControls 的简单表单.我确实在这里做了一个stackblitz示例,请检查我的代码并验证如果禁用名称控件的值是不可能验证的.
I found this post but it cant solve my problem. I can't validate a simple form with FormControls disabled. I did make a stackblitz example here, please check out my code and verify that is impossible to verify the value of the name control if it's disabled.
提前致谢.
推荐答案
如果你不想失去验证,你可以使用 [attr.disabled]="condition ?true : null"
(或任何条件).这使您的控件看起来像是禁用的,但仍处于验证"状态.
If you want not loose the validate you can use
[attr.disabled]="condition ? true : null"
(or any condition). This give your control an apparence of disabled but still is "validating".
这篇关于Angular 5:验证禁用的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文