title: How to use radio buttons dynamically in angular reactive forms array
body: <p>I have a weird problem. I researched a lot but, I could not find any solution for my specific task.</p>
  <p>Here is the problem: I want to build dynamic forms, where I have radio buttons and I want to set true or false on specific form controls.</p>
  <p>question: where is my problem?</p>
  <p><strong>here is template</strong></p>
  <pre><code>&lt;div [formGroup]=&quot;form&quot;&gt;
      &lt;h1 mat-dialog-title&gt;add question&lt;/h1&gt;
      &lt;mat-dialog-content&gt;
          &lt;p&gt;description&lt;/p&gt;
          &lt;div class=&quot;form-group&quot;&gt;
              &lt;editor [apiKey]=&quot;editorKey&quot; [init]=&quot;editorConfig&quot; formControlName=&quot;question&quot;&gt;&lt;/editor&gt;
          &lt;/div&gt;
          &lt;ng-container *ngFor=&quot;let answer of $any(answers.controls); index as i&quot;&gt;
              &lt;ng-container formArrayName=&quot;answers&quot;&gt;
                  &lt;div [formGroup]=&quot;answer&quot; class=&quot;form-group question&quot;&gt;
                      &lt;div&gt;
                          &lt;!-- problem is here, I can't set formControlName --&gt;
                          &lt;input type=&quot;radio&quot; formControlName=&quot;isCorrect&quot; name=&quot;isCorrect&quot;&gt;
                      &lt;/div&gt;
                      &lt;input type=&quot;text&quot; formControlName=&quot;answer&quot; placeholder=&quot;answer #{{i + 1}}&quot;&gt;
                      &lt;div matTooltip=&quot;delete&quot; matTooltipPosition=&quot;above&quot; (click)=&quot;delete(i)&quot;&gt;X&lt;/div&gt;
                  &lt;/div&gt;
              &lt;/ng-container&gt;
          &lt;/ng-container&gt;
          &lt;button (click)=&quot;add()&quot; class=&quot;btn btn-outline-primary&quot;&gt;add answer&lt;/button&gt;
      &lt;/mat-dialog-content&gt;
      &lt;mat-dialog-actions align=&quot;end&quot;&gt;
          &lt;button class=&quot;btn btn-primary&quot;&gt;accept&lt;/button&gt;
      &lt;/mat-dialog-actions&gt;
  &lt;/div&gt;
  </code></pre>
  <p>here is component</p>
  <pre><code>export class AddQuestionDialogComponent implements OnInit {
  
    form!: FormGroup;
    public editorConfig = editorConfig;
    public editorKey = apiKey.key;
    
    constructor(
      private _fb: FormBuilder
    ) { }
  
    ngOnInit(): void {
      this.form = this._fb.group({
        question: new FormControl(``, [Validators.required]),
        answers: new FormArray([], [Validators.required])
      });
    }
  
    get answers(): FormArray {
      return this.form.controls['answers'] as FormArray;
    }
  
    add() {
      this.answers.push(
        this._fb.group({
          answer: new FormControl(``, [Validators.required]),
          isCorrect: new FormControl(false)
        })
      );
    }
    
    delete(i: number) {
      this.answers.removeAt(i);
    }
  }
  </code></pre>