0

I'm trying to add firebase to ionic 3 but I'm getting an error on Object (...) not a function, everything runs well until the subscribe function gets executed then the error shows, I've done all needed integration and here my home.ts code

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { FirstPage } from '../first/first';
import { AskPage } from '../ask/ask';
import {AngularFireDatabase} from 'angularfire2/database'

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})

export class HomePage {
  constructor(public navCtrl: NavController,
  public afd : AngularFireDatabase) {
    this.getDataFromFireBase();
  }

getDataFromFireBase(){
  this.afd.list('/Heros/').valueChanges().subscribe(
     data => {
       console.log(JSON.stringify(data))
     }
  )
}
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • Please what am I doing wrong? thanks for your help. – Lucky Agbaroji Aug 23 '18 at 13:35
  • The firebase is changed a lot for every version of ionic and angular.As far as i remember you need to use Observable in the ionic 3 version (You need at least in the ionic 4+ angular 6 version) – split Aug 23 '18 at 16:19
  • thanks for the reply but i used an observable, .valueChanges().subscribe – Lucky Agbaroji Aug 23 '18 at 16:33
  • Are you sure AngularFireDatabase import all you need ? See https://stackoverflow.com/questions/42376972/best-way-to-import-observable-from-rxjs – split Aug 23 '18 at 16:38

0 Answers0