angular - 一次禁用整个表单(Angular reactive form)

标签 angular typescript angular-reactive-forms angular2-formbuilder

在使用 Reactive 表单时,有没有办法以 Angular 禁用整个表单。我知道可以让它们一个一个地禁用。

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

是否可以禁用整个表单而不是单独禁用每个 Controller ?

最佳答案

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

更新

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

关于angular - 一次禁用整个表单(Angular reactive form),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45854017/

相关文章:

Angular 6 : error TS2315: Type 'ModuleWithProviders' is not generic

Angular 垫选择表单控制

angular - 构建 Angular 库时是否可以使用自定义 Webpack 配置?

带有 ControllerAs 和 TypeScript 类的 AngularJs 指令

angular - 更改 ngControl.valueAccessor 以动态更改组件

typescript - 在 Typescript 项目中添加本地依赖在 JS 中不起作用

angular - 停止 Angular 中的无限循环 react 形式控制更新

angular2 Material 设计 - react 形式 - md-select 不填充默认值

javascript - 让删除图标显示在与电子邮件地址相同的行上

javascript - 如何更改 Angular 2中getUserMedia回调函数中的变量值