I have a list of strings called listcontrols, for every one of this string i need to make a formarray. I want to display this in my html and the label of this display should be the string that are in the listcontrols.

In my console.log I can see that the formArray is created and has the same spelling as the one i am using so this cant be the problem but my html is complaining:

"Cannot find control with unspecified name attribute"

I tried using [formArrayName] and also formArrayName without the brackets i also tried putting my value in strings or in {{ }} but nothing is working :s

<div class="formgroup" *ngFor="let listValue of listControls; let i = index" [formArrayName]=listValue>
  <div [formGroupName]="i">
    <label>{{ listValue }}</label>
  </div>
</div>

This is in my ts:

addList(){
  this.packageTypeForm.addControl(this.packageTypeForm.controls.list.value, this.formBuilder.array([]));
  this.listControls.push(this.packageTypeForm.controls.string.value);
  console.log(this.packageTypeForm.controls);
}

1 Answers

0
Robin Medland On

Found it, in my addList() i mistyped it should be this.listControls.push(this.packageTypeForm.controls.string.value);