Search bar Autocomplete from API

后端 未结 2 1844
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 14:35

I\'m trying to create a book search bar with autocomplete that will show relevant results dynamically with each keypress. Everything is working and I\'m getting the data, but re

2条回答
  •  故里飘歌
    2021-01-26 15:10

    You can directly pass the created observable to the autocomplete control :

    ts

    ...
        searchResult: Observable;
    
              onChanges(): void {
                    this.searchResult = this.searchForm.get('searchBar').valueChanges.pipe(
                     switchMap(val => this.searchService.searchingValue(val))    
                    );
    
                  }
    ...
    

    html

    Book Search

    Loading... {{ option.volumeInfo.title }}

提交回复
热议问题