Ad

Import {AngularFireDatabase, FirebaseListObservable} From 'angularfire2/database'

I'm following a tutorial that was made a year ago and as i follow, i come across a couple of code that seems to be outdated. I 've searched a found a couple of solutions but it sadly doesn't solve mine. Is there therefore a newer way of writing the following code?

import {AngularFireDatabase, FirebaseListObservable} from 'angularfire2/database';
import { AngularFireAuth } from "angularfire2/auth";
import { Observable } from "rxjs/Observable";

this is the error it is printing out.

ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'. src/app/chat-form/chat-form.component.ts(16,15): error TS2339: Property 'sendMessage' does not exist on type 'ChatService'. src/app/services/chat.service.ts(2,30): error TS2305: Module '"C:/Users/Gabriel/stack/School/HVA/JAAR 2/YOUTUBE TYPESCRIPT TUTORIAL/MyAngularApplication/We-chat/node_modules/angularfire2/database/index"' has no exported member 'FirebaseListObservable'. src/app/services/chat.service.ts(4,10): error TS2305: Module '"C:/Users/Gabriel/stack/School/HVA/JAAR 2/YOUTUBE TYPESCRIPT TUTORIAL/MyAngularApplication/We-chat/node_modules/rxjs/Observable"' has no exported member 'Observable'.

Ad

Answer

According to this:

Module '"C:/Users/Gabriel/stack/School/HVA/JAAR 2/YOUTUBE TYPESCRIPT TUTORIAL/MyAngularApplication/We-chat/node_modules/angularfire2/database/index"' has no exported member 'FirebaseListObservable'

It seems you are using angularFire 5.0, then you need to check the following, FirebaseListObservable was removed from the package and deprecated. You need to do the following:

import { AngularFireDatabase } from 'angularfire2/database';

constructor(afDb : AngularFireDatabase) 
{
  afDb.list<Item>('items').valueChanges().subscribe(console.log);
}

If you still want to use the FirebaseListObservable then you need to import it from 'angularfire2/database-deprecated'

Check here to see all the classes in the package angularfire2/database-depracted:

https://github.com/angular/angularfire2/tree/master/src/database-deprecated

Ad
source: stackoverflow.com
Ad