Install Firebase using npm

npm i --save firebase angularfire2
1

Copy firebase script

access the firebase page and copy the secret keys to environment.ts

export const environment = {
  production: true,
  firebase:{
    apiKey: "XXXXX",
    authDomain: "XXXXX",
    databaseURL: "https://xxxxx.firebaseio.com",
    projectId: "xxxxx",
    storageBucket: "xxxxx.appspot.com",
    messagingSenderId: "xxxxx"
  }
};

1
2
3
4
5
6
7
8
9
10
11
12

Register the module in angularFire2

in app.module.ts

//...
import {AngularFireModule} from 'angularfire2';
import {AngularFireDatabaseModule} from 'angularfire2/database';
import {AngularFireAuthModule} from 'angularfire2/auth';

import { environment } from '../environments/environment';

@NgModule({
 //...
  imports: [
    BrowserModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireDatabaseModule,
    AngularFireAuthModule
  ],
 //...
})
//...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Last Updated: 1/14/2019, 12:15:15 AM