In Angular 2.0.0-beta.0 map() and filter() are mis

2019-04-28 07:45发布

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));

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?

2条回答
啃猪蹄的小仙女
2楼-- · 2019-04-28 08:10

import Rxjs like this :

Import * as Rx from "rxjs/Rx";

The operators will be available.

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

查看更多
▲ chillily
3楼-- · 2019-04-28 08:20

Did you try to import this:

import 'rxjs/add/operator/map';

See this issue for more details https://github.com/angular/angular/issues/5632

Hope it helps you, Thierry

查看更多
登录 后发表回答