立即禁用整个表单(Angular 反应式表单) [英] Disable the entire form at once (Angular reactive form)

查看:45
本文介绍了立即禁用整个表单(Angular 反应式表单)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 Reactive 表单时,有什么方法可以在 angular 中禁用整个表单.我知道可以让它们一一禁用.

 this.tempForm = this.fb.group({m26_type: '',m26_name: ''})this.tempForm.get('m26_type').disable();

是否可以禁用整个表单而不是单独禁用每个控制器?

解决方案

this.tempForm.disable();

<块引用>

禁用控件.这意味着控制将免除验证检查并从任何父项的聚合值中排除.其状态为禁用.

如果控件有孩子,所有孩子都会被禁用来维护模型.

链接

更新

Plunker 链接 - https://plnkr.co/edit/CFC4uKpvfE4otJ2PWdkc?p=preview

Is there any way to disable the entire form in angular when using Reactive forms. I know it is possible to make them disable one by one.

 this.tempForm = this.fb.group({
  m26_type:  '',
  m26_name:  ''
 })
this.tempForm.get('m26_type').disable();

Is it possible to disable the whole form rather than make every controller disable separately?

this.tempForm.disable();

Disables the control. This means the control will be exempt from validation checks and excluded from the aggregate value of any parent. Its status is DISABLED.

If the control has children, all children will be disabled to maintain the model.

LINK

UPDATE

Plunker link - https://plnkr.co/edit/CFC4uKpvfE4otJ2PWdkc?p=preview

这篇关于立即禁用整个表单(Angular 反应式表单)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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