Firebase Storage not working with Ionic 3 & AngularFire 4.0.0 rc

Firebase Storage does not work with ion 3 and AngularFire 4.0.0 rc. returning with this error message. firebase.storage () takes either no argument or a Firebase app instance

// TypeError: this.fb.storage is not a function

//Module
import {NgModule} from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import {ProfilePage} from './profile';
import 'firebase/storage'
@NgModule({
declarations: [
ProfilePage,
],
imports: [
IonicPageModule.forChild(ProfilePage),
],
exports: [
ProfilePage
]
})
export class ProfilePageModule {
}
//components

import {Component, Inject} from '@angular/core';
import {NavController, IonicPage} from 'ionic-angular';
import {NgForm} from "@angular/forms";
import {AngularFireAuth} from 'angularfire2/auth';
import {AngularFireDatabase, FirebaseListObservable, FirebaseObjectObservable} from 'angularfire2/database';
import * as firebase from 'firebase'; // for typings
import { FirebaseApp } from 'angularfire2';

@ionicpage()
@component({
selector: 'page-profile',
templateUrl: 'profile.html',
})
export class ProfilePage {

file:any;
forUpLoadRef: FirebaseListObservable;
userRef: FirebaseObjectObservable;
storageRef:any;

constructor(public navCtrl: NavController, public af: AngularFireAuth,
public db: AngularFireDatabase, private fb: FirebaseApp) {}

UploadNewImage(){
this.file = (document.getElementById('inputFileId')).files[0];
console.log("file recived"+ JSON.stringify(this.file.name));
let storageRef = this.fb.storage().ref();
var metadata = {
contentType: 'image/*'
};

this.storageRef.child('images/'+this.file.name).put(this.file,metadata)
}

}

//error
TypeError: this.fb.storage is not a function

      

+3


source to share


1 answer


just add import 'firebase/storage';

to parent module https://github.com/angular/angularfire2/issues/1015



+1


source







All Articles