No provider for AngularFire (Angular 2)

2.9k views Asked by At

(This is not the same as the existing questions about it)

UPDATE: I'm using Angular 2 version 2.2.3 and angularfire2 version 2.0.0-beta.6

In the Chrome console I get the error No provider for AngularFire. In my main.ts I have this:

platformBrowserDynamic().bootstrapModule(AppModule, [
  FIREBASE_PROVIDERS,
  defaultFirebase({
    apiKey: <my-apikey>,
    authDomain: <my-authdomain>,
    databaseURL: <my-databaseurl>,
    storageBucket: <my-storagebucket>
  })
]);

In the tutorials I have seen about this they use bootstrap instead of platformBrowserDynamic().bootstrapModule, but in my version of Angular I can't import just bootstrap.

1

There are 1 answers

0
cartant On BEST ANSWER

Your configuration is a little different to that recommended in the documentation.

The AngularFire2-related parts of the NgModule configuration in one of my applications look like this:

import {
    AngularFireModule,
    AuthMethods,
    AuthProviders
} from 'angularfire2';

...

@NgModule({
    bootstrap: [AppComponent],
    declarations: [AppComponent],
    imports: [
        AngularFireModule.initializeApp({
            apiKey: '<some-key>',
            authDomain: '<some-project-authdomain>',
            databaseURL: '<some-database-URL>',
            storageBucket: '<some-storage-bucket>'
        }, {
            method: AuthMethods.Password,
            provider: AuthProviders.Password
        }),
        BrowserModule,
        ...
    ]
})
class AppModule {}

platformBrowserDynamic().bootstrapModule(AppModule);