Object Object Array Form Angular

Viewed 39

I got the display once I tried to get the sNum [object Object],[object Object],[object Object] and tried the row.sNum.nameRow and I got undefined my question is how to get the nameRow Object? and populate it to the nameRow Array Form? I tried so many things but I failed

 {
    "TName": "POSE",
    "GameName": "LOL"
    "sNum": [
        {
            "id": 116,
            "aID": 323,
            "nameRow": "M",
        },
        {
            "id": 118,
            "aID": 323,
            "NameRow": "M",
        },
        {
            "id": 119,
            "aID": 323,
            "NameRow": "M",
        }
    ]
} 

Here's how I select the row the list and pass data to the parent component

selectedRow(row) {
    this.dialogRef.close({
    tName:row.TName,
    gameName:row.GameName,
    serialNumber:row.sNum

});
  }
}

Here's my FormArray

this.fg = this.fb.group({
      name: [],
      lastname: [],
      Info: this.fb.array([this.item()]),
    });
  }

item(): FormGroup {
    return this.fb.group({
      tName: [''],
      gameName: [''],
      nameRow:['']
    });
  }
  get Info(): FormArray {
    return this.fg.get('Info') as FormArray;
  }

Here's I populate the list in my Form Array

openAlertDialog(index: number) {
    const dialogRef = this.dialog.open(AlertDialogComponent, {});
    dialogRef.afterClosed().subscribe((result) => {
      for (let i = 0; i < result; i++) {
        this.Info.push(this.item());
      }
      for (let i = 0; i <= result; i++) {
        this.Info.at(i).patchValue(result);
      }
    });
  }
0 Answers
Related