tôi sử dụng "angular2 webpack" và "angular2/form, Quan sát", nhưng gặp lỗi, cần giúp đỡ ..angular2 Quan sát tài sản 'debouceTime' không tồn tại trên loại 'Quan sát <any>'
có một hình thức tùy chỉnh 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}); }; }
)});}
tôi có thể tìm tập tin "/projection_direction/node_modules/rxjs/operator/debounceTime.js"
tại sao có lỗi như vậy--
Thuộc tính 'debouceTime' không tồn tại trên loại 'Quan sát'.
tôi thêm 'import" rxjs/add/operator/map "; nhập "rxjs/add/operator/debounceTime" ngay bây giờ; 'trong main.ts ,, nhưng lỗi vẫn là ... –
Tôi tạo ra một plunker cho bạn, mở rộng câu trả lời .. hy vọng nó sẽ giúp –
@ RadimKöhler Tôi nghĩ rằng Plunker là lỗi. Cá nhân tôi thấy lỗi TS 'Đối số của loại '(thuật ngữ: bất kỳ) => void' không thể gán cho tham số kiểu '(giá trị: bất kỳ, chỉ số: số) => ObservableInput <{}>'. Loại 'void' không được gán để nhập 'ObservableInput <{}>' .' – BenRacicot