小编Pra*_*ale的帖子

如何实现搜索键向上的去抖时间

我正在我的应用程序中实现搜索功能,我想在按键时实现去抖时间。谁能帮我解决这个问题吗

超文本标记语言

<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)

debouncing typescript angular

3
推荐指数
1
解决办法
5675
查看次数

标签 统计

angular ×1

debouncing ×1

typescript ×1