Answers for "mat autocomplete async"

1

mat autocomplete async

this.usersForm = this.fb.group({
  userInput: null
})

this.filteredUsers = this.usersForm
  .get('userInput')
  .valueChanges
  .pipe(
    debounceTime(300),
    switchMap(value => this.appService.search({name: value}, 1))
);


<mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
  <mat-option *ngFor="let user of (filteredUsers | async)?.results" [value]="user">
    <span>{{ user.name }}</span>
    <small> | ID: {{user.id}}</small>
  </mat-option>
</mat-autocomplete>
Posted by: Guest on July-22-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language