Linking Angular Project with Fire base

Linking Angular Project with Fire base


1. Fire base Installation
2. Fire base configuration
3. Fire base setup with Angular Project.

1. Fire base Installation

Use the following command to install fire base

Commandnpm install angularfire2 firebase --save

2. Fire base Configuration


a. Go to following link and login with your Gmail Credentials 
Link: https://console.firebase.google.com/
b. Click on Add Project link. 
c. Enter Your Project Name in the field 
d. Select and agree terms and conditions
e. Click on Create Project Button
f. After successful creation of project click on Continue button
g. Home page appear's
h. From side navigation bar Click on Database option
i. You can create a cloud database or Real Time Database (In this we are selecting Real Time database).
j. Scroll a little bit and you will see a Create Database button. Click on Create Database.
K. A popup appear's. Select "START IN TEST MODE" and Click on enable button.
l.Data base page appear's with Data tab selected. Where you can see the Project name as database table name.
m. Now Your data base is ready with default or Empty Data

3. Fire base Setup with Angular Project

a. Go to home page of project. b. From side navigation click on Authentication Tab.
c. On the Top Right Click on Web setup button.
d. API key's and configuration data is visible as follow's 
       var config = { 
              apiKey: "xxxxxxxxxxxxxxxxx", 
              authDomain: "xxxxxxxxxxxx", 
              databaseURL: "xxxxxxxxxxxxxxxxxx", 
              projectId: "xxxxxxxxxxxxxx", 
              storageBucket: "", 
              messagingSenderId: "xxxxxxxxxxxx" 
        };
e. Copy the configuration key's or Object and make a note some where.

4. Changes need in our project are as follow's


a. Open Project in your favorite editor. b. Now Open app.module.ts file of your project import following module's
  1. import { AngularFireModule } from 'angularfire2'; 
  2. import { AngularFireDatabaseModule } from 'angularfire2/database'; 
  3. import { AngularFireAuthModule } from 'angularfire2/auth';
c. Just below the imports section paste your fire base configuration keys or Object 
       var config = { 
              apiKey: "xxxxxxxxxxxxxxxxx", 
              authDomain: "xxxxxxxxxxxx", 
              databaseURL: "xxxxxxxxxxxxxxxxxx", 
              projectId: "xxxxxxxxxxxxxx", 
              storageBucket: "", 
              messagingSenderId: "xxxxxxxxxxxx" 
        };
d. In import's section of @ngModule do the following 
             imports : [ 
                      AngularFireModule.initializeApp(config), 
                      AngularFireDatabaseModule,                        AngularFireAuthModule 
                  ];
e. Now all the module's are imported and can be used in any component's.
f. Done with fire base 

Comments

Popular posts from this blog

Installation and Setup Fire Base with Angular

Pushing Form Data Into Fire base

Updating an existing Object in Angular using firebase