title: Set value of angular material select autocomplete programmatically
body: <p>I have a simple <a href="https://material.angular.io/components/autocomplete/overview" rel="noreferrer">angular material autocomplete</a> function. Now i want to set the value / selected option of this autocomplete programmatically. This is my code:</p>
  
  <p><strong>hardware.component.html</strong></p>
  
  <pre><code>&lt;tr&gt;
      &lt;td class="desc pd7"&gt;Firmware&lt;/td&gt;
      &lt;td&gt;
          &lt;div class="form-group mb0"&gt;
              &lt;mat-form-field class="example-full-width"&gt;
                  &lt;input type="text" placeholder="Select firmware" aria-label="Number" matInput [formControl]="myControlFirmware" [matAutocomplete]="auto1" (keydown.enter)="$event.preventDefault()"&gt;
                  &lt;mat-autocomplete #auto1="matAutocomplete" [displayWith]="displayFirmwares"&gt;
                      &lt;mat-option *ngFor="let firmware of filteredFirmwares | async" [value]="firmware" (onSelectionChange)="getIdFromFirmware($event, firmware)"&gt;
                          {{ firmware.name }}
                      &lt;/mat-option&gt;
                  &lt;/mat-autocomplete&gt;
              &lt;/mat-form-field&gt;
          &lt;/div&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>hardware.component.ts</strong></p>
  
  <pre><code>this.miscellaneousTerminalService.getMiscellaneous('firmware').subscribe(data =&gt; {
      if(data.success) {
          this.availableFirmwares = data.data;
          this.filteredFirmwares = this.myControlFirmware.valueChanges
          .pipe(
              startWith(''),
              map(valFirmware =&gt; this.filterFirmwares(valFirmware))
          );
      }
  });
  
  filterFirmwares(valFirmware: any): any[] {
      return this.availableFirmwares.filter(firmware =&gt; {
          let name = valFirmware.name ? valFirmware.name : valFirmware;
          return firmware.name.toLowerCase().indexOf(name.toLowerCase()) &gt; -1;
      });
  }
  
  displayFirmwares(firmware: any): string {
      return firmware ? firmware.name : firmware;
  }
  
  getIdFromFirmware(event, firmware) {
      if(event.isUserInput) {
          this.selectedFirmware = firmware._id;
  
      }
  }
  </code></pre>
  
  <p>i tried to set my firmware model to the <code>_id</code> of the selected Firmware or the name, but nothing works. How can i set the value programmatically. I'm using Angular Material @V 7</p>