属性'combineLatest'在类型 'typeof Observable' 上不存在



我试图添加一个InstantSearch功能到我的网站。我使用的是Angular 12.2,使用的是一个索引为"book-data"的firestore数据库。我在我的搜索组件中使用以下代码:

import { Component, OnInit } from '@angular/core';
import { AngularFirestore } from 'angularfire2/firestore';
import { Subject } from 'rxjs';
import { Observable } from 'rxjs';
@Component({
selector: 'app-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.css'],
})
export class SearchComponent implements OnInit {
searchterm: string;
startAt = new Subject();
endAt = new Subject();
titel;
startobs = this.startAt.asObservable();
endobs = this.endAt.asObservable();
constructor(private afs: AngularFirestore) {}
ngOnInit() {
Observable.combineLatest(this.startobs, this.endobs).subscribe((value) => {
this.firequery(value[0], value[1]).subscribe((titel) => {
this.titel = titel;
});
});
}
search($event) {
let q = $event.target.value;
this.startAt.next(q);
this.endAt.next(q + 'uf8ff');
}
firequery(start, end) {
return this.afs
.collection('book-data', (ref) =>
ref.limit(4).orderBy('auflage').startAt(start).endAt(end)
)
.valueChanges();
}
}

我从Rxjs中导入了Subject和Observable,也在app-module.ts中。我还试图从rxjs/Rx中获得combinelaest并安装rxjs-compat,但每当我这样做时,代码中的combinelaest元素就会被击中,我无法开始使用ng serve -open。

我很感谢任何进一步的建议:)

我在代码中使用了combinellatest作为独立函数。也许你应该这样使用:

import {combineLatest} from 'rxjs';
combineLatest([...yourObserableList]);

最新更新