在 Angular 2.0.0-beta.0 中,表单输入的 Observable 中缺少 map() 和 filter() [英] In Angular 2.0.0-beta.0 map() and filter() are missing from a form input's Observable

查看:13
本文介绍了在 Angular 2.0.0-beta.0 中,表单输入的 Observable 中缺少 map() 和 filter()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Angular 2.0.0-alpha.47 中,从调用 formInput.valueChanges() 返回的 Observable 具有所有高阶函数,即我可以做这样的事情;

In Angular 2.0.0-alpha.47 the Observable returned from calling formInput.valueChanges() had all the higher order functions i.e I could do something like this;

this.search.valueChanges
 .debounceTime(150)
 .map(x=>return x+1)
 .switchMap(text => this.youtube.search(text));

我现在使用 2.0.0-beta.0 并且从 this.search.valueChanges() 返回的 Observable 不再具有所有方法.我只能订阅.我不能再调用 map()、filter() 等.

I'm now using 2.0.0-beta.0 and the Observable returned from this.search.valueChanges() no longer has all the methods. I can only subscribe. I can no longer call map(), filter() etc.

有谁知道这是否是表单输入的预期行为?

Does anyone know if this is the expected behaviour for form inputs now?

推荐答案

像这样导入 Rxjs :

import Rxjs like this :

Import * as Rx from "rxjs/Rx";

运营商将可用.

当你使用 Observable 类时.. 用 Rx 前缀.( Rx.Observable )

When you use Observable class .. prefix it with Rx. ( Rx.Observable )

这篇关于在 Angular 2.0.0-beta.0 中,表单输入的 Observable 中缺少 map() 和 filter()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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