我在我的离子3应用程序上收到此错误 我安装angularfire 2和firebase并声明配置
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
// import plugins
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { File } from '@ionic-native/file';
import { FileChooser } from '@ionic-native/file-chooser';
import { FilePath } from '@ionic-native/file-path';
import { config } from './app.firebaseconfig';
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireModule } from 'angularfire2';
//import components
import { MyApp } from './app.component';
// import providers
import { AuthProvider } from '../providers/auth/auth';
import { UserProvider } from '../providers/user/user';
import { ImghandlerProvider } from '../providers/imghandler/imghandler';
@NgModule({
declarations: [
MyApp,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp,{tabsPlacement: 'top'}), // placement the tabs in top
AngularFireModule.initializeApp(config)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
],
providers: [
StatusBar,
SplashScreen,
File,
FilePath,
FileChooser,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AuthProvider,
AngularFireAuth,
UserProvider,
ImghandlerProvider
]
})
export class AppModule {}
我有配置组件,我没有在这里导入。 当我将这一行添加到imghandler提供程序
时import firebase from 'firebase';
imghandler.ts
import { Injectable } from '@angular/core';
import { File } from '@ionic-native/file';
import { FileChooser } from '@ionic-native/file-chooser';
import { FilePath } from '@ionic-native/file-path';
import firebase from 'firebase';
@Injectable()
export class ImghandlerProvider {
nativepath: any;
firestore = firebase.storage();
constructor(public filechooser: FileChooser) {
}
uploadimage() {
var promise = new Promise((resolve, reject) => {
this.filechooser.open().then((url) => {
(<any>window).FilePath.resolveNativePath(url, (result) => {
this.nativepath = result;
(<any>window).resolveLocalFileSystemURL(this.nativepath, (res) => {
res.file((resFile) => {
var reader = new FileReader();
reader.readAsArrayBuffer(resFile);
reader.onloadend = (evt: any) => {
var imgBlob = new Blob([evt.target.result], { type: 'image/jpeg' });
var imageStore = this.firestore.ref('/profileimages').child(firebase.auth().currentUser.uid);
imageStore.put(imgBlob).then((res) => {
this.firestore.ref('/profileimages').child(firebase.auth().currentUser.uid).getDownloadURL().then((url) => {
resolve(url);
}).catch((err) => {
reject(err);
})
}).catch((err) => {
reject(err);
})
}
})
})
})
})
})
return promise;
}
}
我收到了这个错误
Firebase:没有创建Firebase应用程序'[DEFAULT]' -
我在stackoverflow中看到了一些解决方案但是这些解决方案使用firebase.intializeApp更改了initalizeapp但是我的是AngularFireModule