如何将 formArray 值重置为默认值?因为 form.reset() 使其为空

How to reset the formArray values to default values ?since form.reset() makes it null

我是 angular 的新手,我有一个包含这些字段的表单。

 this.catform = new FormGroup({
  name: new FormControl('', Validators.required,),
  source: new FormControl('', Validators.required),
  event: new FormControl('', Validators.required),
  cond:  this.fb.array([this.Cond()], Validators.required)     
});

 Cond() : FormGroup {
return this.fb.group({
  disp : new FormControl(1),
  field: new FormControl('', Validators.required),
  ct: new FormControl('', Validators.required),
  value: new FormControl('', Validators.required),
  ot : 'AND'
});
}

提交表单后,我执行了 this.catform.reset(),但这会将“disp”和“ot”重置为 null,从而使我的表单的值为 null。现在,当我再次提交此表单时,它在后端不成功,因为这些值在表单中为空,但后端不接受此 creation.So 我希望这些与我上面提到的一样,我不HTML 模板中有这 2 个字段,因此我无法从 HTML 模板中编辑它们。 如果有人可以提出一些方法,请。

将以下代码转换为方法。而当你想重置的时候,只要调用该方法并将其赋值给this.catform

new FormGroup({
    name: new FormControl('', Validators.required,),
    source: new FormControl('', Validators.required),
    event: new FormControl('', Validators.required),
    cond:  this.fb.array([this.Cond()], Validators.required)
});

像这样:

this.catform=this.getFormgroup();

private getFormgroup() {
    return new FormGroup({
    name: new FormControl('', Validators.required,),
    source: new FormControl('', Validators.required),
    event: new FormControl('', Validators.required),
    cond:  this.fb.array([this.Cond()], Validators.required)
    });
}