TypeError:search.valueChanges.debounceTime不是一个函数

我只是学习angular2。 在应用input变化的时候,我得到了错误。

app.ts:

export class AppComponent { form: ControlGroup; constructor(fb: FormBuilder) { this.form = fb.group({ search: [] }); var search = this.form.find('search'); search.valueChanges .debounceTime(400) .map(str => (<string>str).replace(' ','‐')) .subscribe(x => console.log(x)); }; } 

错误:

在这里输入图像说明

如何解决这个问题? 我错过了什么吗?

Plunker演示

注意我不能生产任何东西,因为我现在正在写第一次冲锋者。 我只在plunker写了我的app.ts代码。 我已经从我的本地电脑显示错误的截图。 如果你告诉我在plunker上运行angular2项目的方式,我也会很感激。

你只需要导入这些来消除你的错误。 您正在获取运行时错误,因为默认情况下Observables只有less数几个运算符。 你必须像这样明确地导入它们 –

 import 'rxjs/add/operator/debounceTime'; import 'rxjs/add/operator/map'; 

工作示例