Автозаполнение Не удается найти другой поддерживающий объект '[object Object]' типа 'object' - PullRequest
0 голосов
/ 29 октября 2018

Я новичок в angular и пытаюсь использовать автозаполнение из этого урока и адаптироваться к своему проекту: https://material.angular.io/components/autocomplete/overview Проблема в том, что после того, как я изменил несколько структур кода, он становится ошибкой, может кто-нибудь сказать мне, что я делаю здесь неправильно. Заранее спасибо.

myControl = new FormControl();
 filteredOptions: Observable<any[]>;
  
   this.configSerivce.getConfig().subscribe( (data:Line)  => {
        this.line=data;
        this.line[this.i].status = false; //added new attribute status
        this.i++;
    });
    
    this.filteredOptions = this.myControl.valueChanges
    .pipe(
      startWith(''),
      map(value => this._filter(value))
    );
    
  private _filter(value: string,line : any): any[] {
    const filterValue = parseInt(value);
    return line.filter(option => option.lineNumber === filterValue);
  }
export interface Line {
    baseVersion?: string;
    netVersion?: number;
    mandator?: string;
    lineNumber?: number;
    shortName?: string;
    name?: string;
    variants?: Array<Variant>;
}
<form class="example-form">
  <mat-form-field class="example-full-width">
    <input type="text"  matInput [formControl]="myControl" [matAutocomplete]="auto">
    <mat-autocomplete #auto="matAutocomplete">
      <mat-option *ngFor="let option of filteredOptions | async" [value]="option.lineNumber">
        {{option.lineNumber}}
      </mat-option>
    </mat-autocomplete>
  </mat-form-field>
</form>
...