AngularFire2 Set up


In order to use Firebase as your database in Angular2 project it is essential to import AngularFire2 library to your project.For this you can refer the GitHub documentation  and get an idea. At first you have to import the library using the following code.
npm install firebase angularfire2 --save
Now move on to your app.module.ts file of your project and import the library. using the below code.
import { AngularFirestore } from 'angularfire2/firestore';
And then you need to export the configuration in the same file.Use the below code to change according to your project.
export const firebaseConfig={
  apikey :'',
  authDomain:'',
  databaseURL:'',
  storageBucket:'',
  messagingSenderID:''
};

Obtain the configurations according to your project through your firebase project.There you will get a similar window as below.

Now import the Module using the following code.
AngularFireModule.initializeApp(firebaseConfig)
Now we need to generate a service.For this create a folder called service 

Now create a service by using the command.
ng g service firebase
Inside it you will get a file called firebase.servie.ts. Open the file.
Then import FirebaseListObservable.
import { AngularFire,FirebaseListObservable } from 'angularfire2';
This will help to absorb data from the database as a list.
constructor(private af: AngularFire) { }
Now  you have already set up the Fire 2 in your Angular2 Project.
Hope to see you soon with a new article.






Comments

Popular posts from this blog

Java Part 2 :How to Install Java

Working with Buttons in Android Studio

Ruby - Dynamic, Open source programming language