问题描述
我正在使用 NgbTypeahead 来显示 API 调用的结果,一切正常,但有时在我按下空格键或退格键之前它不会显示选项, 我观察到这种行为主要是在我重新开始(即刷新页面)之后,它工作得非常好, 谁能帮我这个?提前致谢。
以下是供参考的代码片段:
.ts文件
formatMatches = (value: any) => value.name || '';
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(300),distinctUntilChanged(),switchMap((term) =>
this.searchService.search(term))
)
html
<input type="text" class="form-control"
id="xName"
name="xName"
[(ngModel)]="obj.xName"
(selectItem)="itemSelected($event)"
[ngbTypeahead]="search"
placeholder="search X"
[resultFormatter]="formatMatches"
[inputFormatter]="formatMatches"
required />
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)