title: How to implement select all in angular material drop down angular 5
body: <p>I am using mat-select to display drop down, I need select all functionality in angular drop down.</p>
  
  <p>Below is my html</p>
  
  <pre><code>&lt;mat-select formControlName="myControl" multiple (ngModelChange)="resetSelect($event, 'myControl')"&gt;
      &lt;mat-option&gt;Select All&lt;/mat-option&gt;
      &lt;mat-option [value]="1"&gt;Option 1&lt;/mat-option&gt;
      &lt;mat-option [value]="2"&gt;Option 2&lt;/mat-option&gt;
      &lt;mat-option [value]="3"&gt;Option 3&lt;/mat-option&gt;
  &lt;/mat-select&gt;
  </code></pre>
  
  <p>Here is my ts code</p>
  
  <pre><code>/**
   * click handler that resets a multiple select
   * @param {Array} $event current value of the field
   * @param {string} field name of the formControl in the formGroup
   */
  protected resetSelect($event: string[], field: string) {
      // when resetting the value, this method gets called again, so stop recursion if we have no values
      if ($event.length === 0) {
          return;
      }
      // first option (with no value) has been clicked
      if ($event[0] === undefined) {
          // reset the formControl value
          this.myFormGroup.get(field).setValue([]);
      }
  }
  </code></pre>
  
  <p>Some how its not working properly, kindly help or let me any better way to do this.</p>