我使用了ng-bootstrap typeahed,如果输入的值不在我的选项中,我想禁用输入(如果下拉菜单中有匹配的结果,则将删除或禁用keydown),这是我的搜索功能:
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
map(term => term.length < 2 ? []
: states.filter(v => v.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10))
)
在我的模板中,我将其绑定到[ngbTypeahead]