我正在使用Firestore / Firebase,我正在尝试从我的firebase数据库中获取用户,但是,我收到此错误并且我不确定原因。
ERROR Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
at eval (firestore.js:28)
at ZoneDelegate.invoke (zone.js:388)
at Zone.run (zone.js:138)
at NgZone.runOutsideAngular (core.js:4697)
at new AngularFirestore (firestore.js:26)
at _createClass (core.js:10901)
...
我的服务中的代码在构造函数中获取导师的集合(使用Tutor模型):
import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore';
import { Observable } from 'rxjs/Observable';
import { Tutor } from '../_model/tutor.model';
@Injectable()
export class FirestoreService {
tutorsCollection: AngularFirestoreCollection<Tutor>;
tutorDoc: AngularFirestoreDocument<Tutor>;
tutors: Observable<Tutor[]>;
tutor: Observable<Tutor>;
constructor(public afs: AngularFirestore) {
this.tutorsCollection = this.afs.collection('tutors',
ref => ref.orderBy('name', 'asc'));
}
}
我的package.json:
"dependencies": {
"@angular/animations": "^5.2.9",
"@angular/cdk": "^5.2.4",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "^5.2.4",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"angular-material": "^1.1.8",
"angularfire2": "^5.0.0-rc.8.1-next",
"bootstrap": "^3.3.7",
"bootstrap-vertical-tabs": "^1.2.2",
"core-js": "^2.4.1",
"countup.js-angular2": "^1.1.1",
"firebase": "^5.0.4",
"hammerjs": "^2.0.8",
"jquery": "^3.3.1",
"ng2-filter-pipe": "^0.1.10",
"ng2-search-filter": "^0.4.7",
"rxjs": "^5.5.11",
"rxjs-compat": "^6.2.0",
"zone.js": "^0.8.19"
},
我的环境。:
export const environment = {
production: false,
firebase: {
apiKey: ...,
authDomain: ...,
databaseURL: ...,
projectId: ...,
storageBucket: ...,
messagingSenderId: ...
}
};
我知道Firebase更新存在一些破坏和一些兼容性问题,但不确定我哪里出错了。
答案 0 :(得分:0)
请将您的rxjs版本更新为6,这很可能是您的解决方案。
这是一个包含相同问题和我的解决方案的链接:Object error
您需要更新rxjs版本,因为angularfire2要求版本6高于rc7甚至更早。
答案 1 :(得分:0)
请尝试以下代码:
npm install rxjs@6 rxjs-compat@6 --save