Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67441

Angular Materials autocomplete data loading but not filtering working perfectly angular 6

$
0
0

This is my HTML code. form the example I took the code. sample code. But filtering when typing is not working

<mat-form-field appearance="outline">
  <input type="text" formControlName="planClient" matInput placeholder="Plan Client" [matAutocomplete]="auto">
  <mat-autocomplete #auto="matAutocomplete">
    <mat-option *ngFor="let client of filteredOptions | async" [value]="client">
      {{client}}
    </mat-option>
  </mat-autocomplete>
</mat-form-field>

This is my .ts file

filteredOptions: Observable<string[]>;
clients: string[] = [
  'Alabama',
  'California',
  'Colorado',
  'Connecticut',
  'SelectHealth',
  'UMR'
];
planClient = new FormControl();

this.filteredOptions = this.planClient.valueChanges
  .pipe(
    startWith(''),
    map(value => this._filter(value))
  );

public _filter(value: string): string[] {
  const filterValue = value.toLowerCase();
  return this.clients.filter(client => client.toLowerCase().includes(filterValue));
}

Viewing all articles
Browse latest Browse all 67441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>