4

i had problem to

import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database";

i imported AngularFireDatabase but FirebaseListObservable was under a red line after searching this post helped me resolve my problem Getting an error: "Has no exported member AngularFire, AuthProviders, AUthMethods, FirebaseListObservable" in AngularFire2?

import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database-deprecated"; 

but when i compile i get and it cant help i dont know what to do where searching ect core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: No provider for AngularFireDatabase! Error: No provider for AngularFireDatabase!

"angularfire2": "^5.0.0-rc.2", "core-js": "^2.4.1", "firebase": "^4.5.0",

5 Answers 5

8

i got the answer after reading https://github.com/angular/angularfire2/blob/master/CHANGELOG.md 5.0.0-rc.0 (2017-10-03)

the -deprecated allows you to use the old database API

import { AngularFireDatabaseModule } from 'angularfire2/database-deprecated';

in the app.module.js and in your service you use

 import { AngularFireDatabase, FirebaseListObservable } from "angularfire2/database-deprecated";

thank you both of you, you helped me

Sign up to request clarification or add additional context in comments.

Comments

7

In angularfire2": "^5.0.0-rc.2 you can't use FirebaseListObservable instead you will have to use

import { AngularFireDatabase } from 'angularfire2/database';

and use it like this

constructor(public af: AngularFireDatabase) {
  let restaurants = this.af.list('/path');
}

Comments

0

You need to import the following and add it under your app.module.ts

import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireDatabaseModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

3 Comments

which config? did you add it to your module?
BrowserModule, RouterModule.forRoot(appRoutes), FormsModule, AngularFireAuthModule, AngularFireDatabaseModule, AngularFireModule.initializeApp(environment.firebase),
0

You can't use FirebaseListObservable in current version of angularfire2.
It worked in old version of angularfire2 like 4.0.0-rc.1.

So, install it and it will work totally fine (in terminal):

npm i [email protected]

and import:

import {AngularFireDatabase,FirebaseListObservable} from 'angularfire2/database';

import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';

Comments

-1

This might be late, but in case anyone still wonders what they can use as an alternative, note that FirebaseListObservable has been deprecated.

However, in the latest version of firebase note that you can use AngularFireList, and import it as so...

import { AngularFireDatabase , AngularFireList} from '@angular/fire/database';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.