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
Command: npm install angularfire2 firebase --save
2. Fire base Configuration
a. Go to following link and login with your Gmail CredentialsLink: https://console.firebase.google.com/b. Click on Add Project link.c. Enter Your Project Name in the fieldd. Select and agree terms and conditionse. Click on Create Project Buttonf. After successful creation of project click on Continue buttong. Home page appear'sh. From side navigation bar Click on Database optioni. 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'svar 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
- import { AngularFireModule } from 'angularfire2';
- import { AngularFireDatabaseModule } from 'angularfire2/database';
- import { AngularFireAuthModule } from 'angularfire2/auth';
c. Just below the imports section paste your fire base configuration keys or Objectvar config = {apiKey: "xxxxxxxxxxxxxxxxx",authDomain: "xxxxxxxxxxxx",databaseURL: "xxxxxxxxxxxxxxxxxx",projectId: "xxxxxxxxxxxxxx",storageBucket: "",messagingSenderId: "xxxxxxxxxxxx"};d. In import's section of @ngModule do the followingimports : [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
Post a Comment