当我尝试在angularfire2应用程序上使用rtdb时,我收到此错误。
ERROR TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_2__.database is not a function
at new AuthService (auth.service.ts:29)
at _createClass (core.js:9272)
at _createProviderInstance$1 (core.js:9234)
at resolveNgModuleDep (core.js:9200)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:9911)
at resolveDep (core.js:10276)
at createClass (core.js:10152)
at createDirectiveInstance (core.js:10033)
at createViewNodes (core.js:11255)
at callViewAction (core.js:11571)
我按如下方式导入了firebase:
import * as firebase from 'firebase/app';
以下给出了上述错误:
db = firebase.database();
答案 0 :(得分:0)
像这样导入:
import * as firebase from 'firebase';
import 'firebase/firestore';
答案 1 :(得分:0)
使用AngularFire2,可以通过npm
进行确认