title: patchValue on a FormArray object?
body: <p>I have an array of languages for a user to select and a default language to pick.  When a default language is selected, I want to make sure the checkbox for that language is also selected programmatically.</p>
  
  <p>I'm not sure how to use patchValue on the FormArray of languages.</p>
  
  <p><strong>component.ts</strong></p>
  
  <pre><code>import { FormGroup, FormControl, FormArray, Validators } from '@angular/forms';
  ...
  
  constructor(...) {
      this.languages = ['English', 'Spanish', 'Mandarin', 'Klingon'];
  
      this.myForm = new FormGroup({
          languages: this.createLanguagesControl(),
          defaultLanguage: new FormControl('', Validators.required)
      });
  }
  
  createLanguagesControl() {
      const controls = this.languages.map(language =&gt; {
          return new FormControl(false);
      });
      return new FormArray(controls);
  }
  
  defaultLanguageSelection() {
      let formValues = this.myForm.value;
      console.log('defaultLanguageSelection', formValues.defaultLanguage);
  
      let i = 0;
      for (let language of this.languages) {
          if (language == formValues.defaultLanguage) {              // find the index of our newly-selected default language in the languages array
              this.myForm.patchValue({languages: {i: true}});        // make sure the language is checked
          }
          i++;
      }
  }
  </code></pre>
  
  <p><strong>component.html</strong></p>
  
  <pre><code>&lt;mat-card-content&gt;
  
      &lt;div formArrayName="languages" *ngFor="let language of languages; index as i"&gt;
          &lt;mat-checkbox formControlName="{{ i }}"&gt;
              {{ language }}
          &lt;/mat-checkbox&gt;
      &lt;/div&gt;
  
      &lt;mat-form-field&gt;
          &lt;mat-label&gt;Default Language&lt;/mat-label&gt;
          &lt;mat-select formControlName="defaultLanguage"&gt;
              &lt;mat-option *ngFor="let language of languages" [value]="language" (click)="defaultLanguageSelection()"&gt;
                  {{ language }}
              &lt;/mat-option&gt;
          &lt;/mat-select&gt;
      &lt;/mat-form-field&gt;
  
  &lt;/mat-card-content&gt;
  </code></pre>