按照 Angular 更新指南将我的 Angular 5 项目更新为 Angular 6 后,我得到了。
Property 'debounceTime' does not exist on type 'Observable<any>'
运行ng update
后,我的所有组件都丢失了debounceTime import
。但是我手动将其放回原处,但这并没有解决问题。
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();
},
我真的很想了解这里发生了什么。
您需要使用管道运算符。
this.searchField.valueChanges
.pipe(debounceTime(800),
distinctUntilChanged()
)
.subscribe(term => {
this.searchText = term;
this.getAllDoctors();
}),