Angular 5:验证禁用字段 [英] Angular 5: Validating disabled fields

查看:109
本文介绍了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.

Stackblitz代码

谢谢.

推荐答案

@Eliseo的解决方案:

Solution by @Eliseo:

如果您不想松散验证,则可以使用[attr.disabled] ="true"(或任何条件).这使您的控件外观为已禁用,但仍在验证"中.

If you want not loose the validate you can use [attr.disabled]="true" (or any condition). This give your control an apparence of disabled but still is "validating".

这篇关于Angular 5:验证禁用字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆