title: Angular Reactive Form with dynamic fields
body: <p>I'm currently battling with Angular form array.</p>
  
  <p>I have a form in which I add the fields dynamically.</p>
  
  <p>I have created the form object:</p>
  
  <pre><code>this.otherDataForm = this.fb.group({
  });
  </code></pre>
  
  <p>I add the dynamic fields like this:</p>
  
  <pre><code>addField(field: CustomFormField): void {
      this.otherDataForm.addControl(id_campo, new FormControl('', Validators.required));
  }
  </code></pre>
  
  <p>I loop through those fields:</p>
  
  <pre><code>&lt;form *ngIf="selectedProfile" [formGroup]="otherDataForm"&gt;
        &lt;div class="mb-3" *ngFor="let field of fields; let i = index"&gt;
             &lt;label&gt;{{field.descripcion}}&lt;/label&gt;
             &lt;input class="form-control" [formControlName]="field.id_campo" type="number"&gt;
        &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>But I can't seem to get control of the errors of each field to show a validation message if the field is required.</p>
  
  <p>Anyone can help me with this one?
  Maybe there is a better way to do this.</p>