首页 > 解决方案 > 当在 FormControlName 上调用 disabled() 使整个表单无效时如何解决?

问题描述

我正在使用反应形式,当我使 formControlName 禁用()时,整个表单无效。我想在禁用后有效。

  console.log('Before:'+ (this.form.valid));
  this.form.controls['formControlName1'].disable();//calling in onInit()
  console.log('After:'+(this.form.valid));

  output-:
  Before:true
  After:false.

标签: angulartypescript

解决方案


formControlName.disable({onlySelf: true});

推荐阅读