I use "angular2 webpack" and "angular2/form,Observable" , but met an error ,need help ..
There is a custom form validator --
import {Observable} from 'rxjs/Rx';
import {REACTIVE_FORM_DIRECTIVES,FormControl, FormGroup, Validators} from '@angular/forms';
emailShouldBeUnique(control:FormControl) {
return new Observable((obs:any)=> {
control.valueChanges
.debouceTime(400)
.distinctUntilChanged()
.flatMap(term=>return !this.userQuery.emailExist(term))
.subscribe(res=> {
if (!res) {obs.next(null)}
else {obs.next({'emailExist': true}); }; }
)});}
I could find the file "/projection_direction/node_modules/rxjs/operator/debounceTime.js"
why is there such the error--
Property 'debouceTime' does not exist on type 'Observable'.
For me, the answer was using the pipe:
Plus changing the import from:
To:
And yes, I was following a tutorial, so hopefully this helps
I had same problem recently, and solved after I did:
And also added pipe as it is required I think for Angular 5+
You have a typo here. It's debounceTime, not debouceTime :)
I recently had a similar error while working with angular v5.2.6 and rxjs v5.5.6 on an angular-cli 1.6.8 generated project. I originally had:
since I was subscribing for a control valueChanges event and I kept getting the error until I put
I hope this helps!
Let's say you have to use debounceTime() with multiple RxJS operators, I would suggest use .pipe() operator
For everyone coming here after rxjs 6:
You now need to use a
pipe()
:What was
needs now to be:
https://www.learnrxjs.io/operators/filtering/debouncetime.html