“错误类型错误:对象(...)不是函数"使用AngularFirestore和Firebase [英] "ERROR TypeError: Object(...) is not a function" using AngularFirestore and firebase
问题描述
我想在我的应用程序中使用firebase和angularfire2,首先,我安装了它们,并进行了声明:
I want to use firebase and angularfire2 in my app, first of all, I installed them, and for the declarations:
在environment.ts
in environment.ts
export const environment = {
production: false,
firebase: {
apiKey: 'sfsdfdsff',
authDomain: 'sfsdfdf',
databaseURL: 'https://ng-sfsdfsf.firebaseio.com',
projectId: 'ng-fitnesssfsdfdsf',
storageBucket: 'ng-fsdfsdfsfdecff5.appspot.com',
messagingSenderId: '21331323'
}
};
在app.module.ts中,导入:
in app.module.ts, imports:
AngularFireModule.initializeApp(environment.firebase),
AngularFirestoreModule
在要获取我的数据的组件中:
in the component where want to get my data:
import { AngularFirestore } from 'angularfire2/firestore';
直到这一刻,我还没有出错,但是当我想在构造函数中声明我的变量以使用它时:
until this moment I have not an error, but when I want to declare my variable in the constructor to use it:
constructor(private trainingService: TrainingService, private
db:AngularFirestore) { }
我有一个错误:
ERROR TypeError: Object(...) is not a function
at eval (firestore.js:28)
at ZoneDelegate.invoke (zone.js:388)
at Zone.run (zone.js:138)
在我的package.json中:
In my package.json:
"angularfire2": "^5.0.0-rc.8.0",
"core-js": "^2.4.1",
"firebase": "^5.0.2",
我不知道为什么吗?
感谢您的帮助
推荐答案
我遇到了同样的问题,但是我解决了.你可以关注我的工作.这是离子性的一个例子.
I had same problem but i solved it. You can follow my work. This is a example for ionic.
安装rxjs
npm i rxjs@^6.0 rxjs-compat
将rxjs-compact导入文件
import rxjs-compact to file
import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
import { Observable } from 'rxjs-compat';
import { map } from 'rxjs-compat/operators';
https://stackoverflow.com/a/50447449/6567753
这篇关于“错误类型错误:对象(...)不是函数"使用AngularFirestore和Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!