Я пытаюсь использовать угловое автозаполнение материала, и, пытаясь получить данные из базы данных, выдает эту ошибку. Типу «Наблюдаемый» не хватает следующих свойств из типа «строка []»: длина, поп, толчок, конкат и еще 25.
my component.ts
export class SearchComponent implements OnInit {
constructor(private reservationService: ReservationService, private searchService: SearchService){}
location;
CheckIn;
AdultNumber;
myControl = new FormControl();
options: string[] = ['One', 'Two', 'Three'];
filteredOptions: Observable<string[]>;
regions: string[];
ngOnInit() {
this.filteredOptions = this.myControl.valueChanges
.pipe(
startWith(''),
map(value => this._filter(value))
);
this.reservationService.getRegions().subscribe((data: Observable<string[]>)=>{
console.log(data);
this.regions= data; // ERROR IS HERE ERROR ERROR ERROR
})
/* this.reservationService.getRegions().subscribe(sa => console.log(sa)); */
}
getregionlist(){
console.log(this.location,"location")
console.log(this.CheckIn,"checkindate")
console.log(this.AdultNumber,"AdultNumber")
console.log(this.array,"array")
}
private _filter(value: string): string[] {
const filterValue = value.toLowerCase();
return this.regions.filter(option => option.toLowerCase().includes(filterValue));
}
my service.ts
getRegions(){
return this._http.get("https://localhost:44389/api/locations");
}
my html
<mat-form-field class="example-full-width">
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let option of filteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>