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'.
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
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM