Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Angular 2.0.0-beta.0 map() and filter() are missing from a form input's 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));

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?

like image 507
screenm0nkey Avatar asked Dec 21 '15 11:12

screenm0nkey


2 Answers

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 )

like image 135
Mourad Zouabi Avatar answered Nov 15 '22 07:11

Mourad Zouabi


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

like image 25
Thierry Templier Avatar answered Nov 15 '22 08:11

Thierry Templier