AngularFire 和 Firebase - 可以同时使用两者吗?
AngularFire and Firebase - possible to use both?
我将 Ionic2 与 Firebase 结合使用。我在 app.ts 中看到了两种初始化 firebase 的方法
这样做的首选方式是什么以及如何使用这两个功能?当我在 ionicBootstrap() 中初始化时,我失去了 firebase 函数,当我在构造函数中初始化时,我失去了 angularfire 函数。
要使用angularfire函数,在ionicBootstrap中初始化
ionicBootstrap(MyApp, [
FIREBASE_PROVIDERS,
// Initialize Firebase app
defaultFirebase({
apiKey: "XXXXXX-XXXXXXXXXXXXXXXXXX-XXXXXX",
authDomain: "XXXXXX.firebaseapp.com",
databaseURL: "https://XXXXXX.firebaseio.com",
storageBucket: "XXXXXX.appspot.com"
}),
provide('AppStore', { useValue: appStore }) ])
要使用firebase函数,在构造函数中初始化
constructor(private platform:Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
// Initialize Firebase
var config = {
apiKey: "XXXXXX-XXXXXXXXXXXXXXXXXX-XXXXXX",
authDomain: "XXXXXX.firebaseapp.com",
databaseURL: "https://XXXXXX.firebaseio.com",
storageBucket: "XXXXXX.appspot.com"
};
firebase.initializeApp(config);
});
}
我试图在构造函数中为 angularfire2 移动 defaultFirebase(),但没有成功。我收到此错误:
ORIGINAL EXCEPTION: No provider for Token FirebaseUrl! (AngularFire ->
Token FirebaseUrl)
用这个 SO question/answer 找到了解决方案。
我正在使用 ionicBootstrap() 来初始化 firebase 并替换
import * as firebase from 'firebase';
来自
declare var firebase : any;
我将 Ionic2 与 Firebase 结合使用。我在 app.ts 中看到了两种初始化 firebase 的方法 这样做的首选方式是什么以及如何使用这两个功能?当我在 ionicBootstrap() 中初始化时,我失去了 firebase 函数,当我在构造函数中初始化时,我失去了 angularfire 函数。
要使用angularfire函数,在ionicBootstrap中初始化
ionicBootstrap(MyApp, [
FIREBASE_PROVIDERS,
// Initialize Firebase app
defaultFirebase({
apiKey: "XXXXXX-XXXXXXXXXXXXXXXXXX-XXXXXX",
authDomain: "XXXXXX.firebaseapp.com",
databaseURL: "https://XXXXXX.firebaseio.com",
storageBucket: "XXXXXX.appspot.com"
}),
provide('AppStore', { useValue: appStore }) ])
要使用firebase函数,在构造函数中初始化
constructor(private platform:Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
// Initialize Firebase
var config = {
apiKey: "XXXXXX-XXXXXXXXXXXXXXXXXX-XXXXXX",
authDomain: "XXXXXX.firebaseapp.com",
databaseURL: "https://XXXXXX.firebaseio.com",
storageBucket: "XXXXXX.appspot.com"
};
firebase.initializeApp(config);
});
}
我试图在构造函数中为 angularfire2 移动 defaultFirebase(),但没有成功。我收到此错误:
ORIGINAL EXCEPTION: No provider for Token FirebaseUrl! (AngularFire -> Token FirebaseUrl)
用这个 SO question/answer 找到了解决方案。
我正在使用 ionicBootstrap() 来初始化 firebase 并替换
import * as firebase from 'firebase';
来自
declare var firebase : any;