title: Angular 12 FormGroup dynamically Array checkboxes custom validator does not work
body: <p>I am creating an Angular 12 app, with Material.</p>
  <p>I have a form with an checkbox array loaded dynamically from database.</p>
  <p>I need to validate that at least one checkbox is selected</p>
  <p>I defined like this in my <code>OnInit()</code>:</p>
  <pre><code> ngOnInit(): void {
      this.form = this.fb.group({
        Id: new FormControl(null),
        Name: new FormControl('',Validators.required),
        Recipents: new FormControl('',[Validators.required, matchingEmailValidator()]),
        IsActive: new FormControl(true),
        ProcessorName: new FormControl('',Validators.required),
        Channel: new FormArray([]),
      }, { validators: [customValidateArrayGroup()] }
      );
  }
  </code></pre>
  <p>I need a custom validation for channel form array. If I added it in the definition of the channel, it does not fire when I check it. So, I decided to do it at the form level..</p>
  <p>I added:</p>
  <pre><code>{ validators: [customValidateArrayGroup()] }
  </code></pre>
  <p>Every time an object changes, it fires this validator.</p>
  <p>This is my custom validator:</p>
  <pre><code>export function customValidateArrayGroup(): ValidatorFn {
    return function validate(formGroup: FormGroup) {
      let checked = 0
      Object.keys(formGroup.controls).forEach(key =&gt; {
        const control = formGroup.controls[key]
        if (control.value) {
          checked++
        }
      })
  
      if (checked &lt; 1) {
        return {
          requireCheckboxToBeChecked: true,
        }
      }
      return null
    }
  }
  </code></pre>
  <p>Here is my Html where I defined the Checkbox Array</p>
  <pre><code> &lt;mat-label&gt;&lt;strong&gt;Channel&lt;/strong&gt;&lt;/mat-label&gt;
            &lt;li *ngFor=&quot;let chanel of notification.NotificationChannelLogLevels&quot;&gt;
              &lt;mat-checkbox id= {{chanel.NotificationLogLevel.Id}} formArrayName=&quot;Channel&quot;
              [checked]=&quot;chanel.IsActive&quot;
               (change)=&quot;changeEventFunc($event)&quot;&gt;
                {{chanel.NotificationLogLevel.Name}}
              &lt;/mat-checkbox&gt;
            &lt;/li&gt;
  </code></pre>
  <p>The problem I have is that the custom validator does not fire when a checkbox is clicked. Maybe is becouse they are loaded dinamically and are not recognized by <strong>formGroup.controls</strong></p>
  <p>How can I validate this?</p>