我正在使用ngbTypeahead。在我的示例中,如果搜索文本不匹配,我想显示消息。能否请您提出建议,我该如何显示消息? 这是我的代码。
add.tool.component.ts
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
merge(this.focus$),
merge(this.click$.pipe(filter(() => !this.instance.isPopupOpen()))),
map(term => (term === '' ? ''
: this.requestedTools.filter(v => v.name.toLowerCase().indexOf(term.toLowerCase()) > -1)).slice(0, 10))
);
formatter = (x: { name: string }) => x.name;
add.tool.component.html
<div class="input-group input-width">
<input type="text" class="form-control" #instance="ngbTypeahead" placeholder="Search" aria-label="Search"
[(ngModel)]="requestedTool"
[ngbTypeahead]="search" />
<span class="search-icon-position">
<button type="button" class="btn btn-primary bg-transparent">
<span class="fa fa-search search-icon-right"></span>
</button>
</span>
</div>