Angular6 属性“debounceTime"在“Observable<any>"类型上不存在? [英] Angular6 Property 'debounceTime' does not exist on type 'Observable<any>'?

查看:28
本文介绍了Angular6 属性“debounceTime"在“Observable<any>"类型上不存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照Angular 更新指南将我的 Angular 5 项目更新为 Angular 6 后,我得到了.

After updating my Angular 5 project into Angular 6 following Angular update guide i'm getting.

Property 'debounceTime' does not exist on type 'Observable<any>'

运行 ng update 后,我的所有组件都丢失了 debounceTime 导入.但我手动放回了它,但这并没有解决问题.

after running ng update my all components lost the debounceTime import. But i put it back manually but that didn't fixed the issue.

example.component.ts

import { debounceTime } from 'rxjs/operators';
 //Added after removed by ng update

 this.searchField.valueChanges
  .debounceTime(800)
  .distinctUntilChanged()
  .subscribe(term => {
    this.searchText = term;
    this.getAllDoctors();
  },

我真的很想了解这里发生了什么.

I really want to understand whats going on here.

推荐答案

您需要使用管道运算符.

You need to use pipe operator.

this.searchField.valueChanges
  .pipe(debounceTime(800),
        distinctUntilChanged()
   )
  .subscribe(term => {
    this.searchText = term;
    this.getAllDoctors();
  }),

这篇关于Angular6 属性“debounceTime"在“Observable&lt;any&gt;"类型上不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆