我正在我的应用程序中实现搜索功能,我想在按键时实现去抖时间。谁能帮我解决这个问题吗
超文本标记语言
<div class="mt-4">
<div class="form-group has-search">
<span class="fa fa-search form-control-feedback"></span>
<input type="search" class="form-control" [(ngModel)]="searchKeywords" (keyup)="getSmartSearchValues(searchKeywords)" (search)="clearSearch()" placeholder="Search here">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这个,但它显示错误
searchTextChanged = new Subject<string>();
ngOnInit(): void {
this.subscription = this.searchTextChanged
.debounceTime(1000)
.distinctUntilChanged()
.mergeMap(search => this.getSmartSearchValues('', ''))
.subscribe(() => { });
this.getAllData();
if (this.CoffeeItemList.length === 0) {
this.empty = true;
}
this.getItemsCount('');
}
Run Code Online (Sandbox Code Playgroud)
错误
Property 'debounceTime' does not exist on type 'Subject<string>'.
Property 'subscription' does not exist on type 'AppComponent'
Run Code Online (Sandbox Code Playgroud)