将我的 Angular 5 项目更新为 Angular 6 之后 Angular update guide我得到。
Property 'debounceTime' does not exist on type 'Observable<any>'
运行后
ng update
我的所有组件都丢失了 debounceTime import
.但是我手动放回了它,但这并没有解决问题。示例.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();
},
我真的很想了解这里发生了什么。
最佳答案
您需要使用管道运算符。
this.searchField.valueChanges
.pipe(debounceTime(800),
distinctUntilChanged()
)
.subscribe(term => {
this.searchText = term;
this.getAllDoctors();
}),
关于Angular6 属性 'debounceTime' 在 'Observable<any>' 类型上不存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51917433/