“ERROR TypeError: Object(...) is not a function";使用 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
这篇关于“ERROR TypeError: Object(...) is not a function";使用 AngularFirestore 和 firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!