Javascript FormArray无效,但不包含错误

Javascript FormArray无效,但不包含错误,javascript,angular,angular6,angular-reactive-forms,Javascript,Angular,Angular6,Angular Reactive Forms,我在第六章中使用了反应形式。此反应式表单包含一个名为instruments的FormGroup,它是一个FormArray 我收到的信息是,form array无效,但数组的所有组件均有效 有什么问题吗 初始化表格 initializeForm(laboratory) { this.laboratoryForm = this.formBuilder.group({ laboratoryId: [laboratory && laboratory.Id],

我在第六章中使用了反应形式。此反应式表单包含一个名为
instruments
FormGroup
,它是一个
FormArray

我收到的信息是,form array无效,但数组的所有组件均
有效

有什么问题吗

初始化表格

initializeForm(laboratory) {
    this.laboratoryForm = this.formBuilder.group({
      laboratoryId: [laboratory && laboratory.Id],
      clientId: [this.currentUserClientId],
      name: [laboratory && laboratory.Name, [Validators.required, Validators.maxLength(50)]],
      code: [laboratory && laboratory.Code, [Validators.required, Validators.maxLength(5)]],
      description: [laboratory && laboratory.Description, [Validators.required, Validators.maxLength(1000)]]
    });
    if (laboratory && laboratory.LaboratoryInfoSystem) {
      let laboratoryInfoSystemFormGroup = this.formBuilder.group({
        id: [laboratory.LaboratoryInfoSystem.Id],
        description: [laboratory.LaboratoryInfoSystem.Description, [Validators.maxLength(1000)]],
        model: [laboratory.LaboratoryInfoSystem.Model, [Validators.required, Validators.maxLength(50)]],
        name: [laboratory.LaboratoryInfoSystem.Name, [Validators.required, Validators.maxLength(50)]],
        lis_connection: this.formBuilder.group({
          id: [laboratory.LaboratoryInfoSystem.LaboratoryInfoSystemConnection.id],
          connection: [laboratory.LaboratoryInfoSystem.LaboratoryInfoSystemConnection.Connection, [Validators.required, Validators.maxLength(1000)]],
          connectionTypeId: [laboratory.LaboratoryInfoSystem.LaboratoryInfoSystemConnection.ConnectionTypeId, [Validators.required]],
          username: [laboratory.LaboratoryInfoSystem.LaboratoryInfoSystemConnection.Username, [Validators.maxLength(100)]],
          password: [laboratory.LaboratoryInfoSystem.LaboratoryInfoSystemConnection.Password, [Validators.maxLength(100)]]
        })
      });
      this.laboratoryForm.addControl('laboratoryInfoSystem', laboratoryInfoSystemFormGroup);
    }

    if (laboratory && laboratory.Instruments) {
      let formInstrumentsArray = laboratory.Instruments.map(function (instrument) {
        return this.getInstrumentForm(instrument.Model, instrument.Name, instrument.Description, instrument.InstrumentConnection);
      }.bind(this));
      this.laboratoryForm.addControl('instruments', this.formBuilder.array(formInstrumentsArray));
    }
  }

getInstrumentForm
函数

 getInstrumentForm(model, name, description, instrumentConnection): FormGroup {
return this.formBuilder.group({
  model: [model, [Validators.required, Validators.maxLength(50)]],
  name: [name, [Validators.required, Validators.maxLength(50)]],
  description: [description, [Validators.maxLength(1000)]],
  instrument_connection: this.formBuilder.group({
    id: [instrumentConnection && instrumentConnection.Id],
    connection: [instrumentConnection && instrumentConnection.Connection, [Validators.required, Validators.maxLength(1000)]],
    connectionTypeId: [instrumentConnection && instrumentConnection.ConnectionTypeId, [Validators.required]],
  })
});
}

请看一下。我将从以下内容开始,然后如果看到这已解决了错误

您具有以下功能:

let formInstrumentsArray=实验室.仪器.地图(功能(仪器){
返回此.getInstrumentForm(instrument.Model、instrument.Name、instrument.Description、instrument.InstrumentConnection);
}.约束(这个);
将映射的工具转换为表单数组中的表单控件时缺少了这一点。在我的例子中,我有:

const-toppingsFGs=toppings.map(topping=>this.fb.group(topping));
对于您来说,您需要了解预处理过程,然后将其传递到映射结果中,并将其传递到组中

let formInstrumentsArray=实验室.仪器.地图(功能(仪器){
返回此.getInstrumentForm(instrument.Model、instrument.Name、instrument.Description、instrument.InstrumentConnection);
}.约束(这个);
让final=formInstrumentsArray.map(instrument=>this.fb.group(instrument));

请将您格式的代码添加到您正在为表单数组设置表单组的部分。
getInstrumentForm
返回一个
FormGroup
@MihaiAlexandru Ionut请用代码更新问题