Angular_Fire combines the power of Angular with the flexibility of Firebase. This project allows developers to create dynamic, real-time applications with minimal effort. With Angular’s robust framework and Firebase’s backend services, you can focus on building features without worrying about server management.
To get started with Angular_Fire, follow these steps:
git clone https://github.com/jayant-cell/Angular_Fire.git
cd Angular_Fire
npm install
src/environments/environment.ts
and add your Firebase config:
export const environment = {
production: false,
firebase: {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_STORAGE_BUCKET",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID"
}
};
ng serve
http://localhost:4200
.After setting up the project, you can start building your application. Here are some examples of how to use the features:
To fetch real-time data from Firestore:
import { AngularFirestore } from '@angular/fire/firestore';
constructor(private firestore: AngularFirestore) {}
getItems() {
return this.firestore.collection('items').valueChanges();
}
To enable offline data persistence:
import { AngularFirestore } from '@angular/fire/firestore';
constructor(private firestore: AngularFirestore) {
this.firestore.firestore.enablePersistence()
.catch((err) => {
console.error('Persistence failed', err);
});
}
Set up push notifications using Firebase Cloud Messaging:
import { AngularFireMessaging } from '@angular/fire/messaging';
constructor(private afMessaging: AngularFireMessaging) {
this.afMessaging.requestToken.subscribe(
(token) => {
console.log('Permission granted! Save to the server!', token);
},
(error) => {
console.error('Unable to get permission to notify.', error);
}
);
}
Set up NgRx to manage your application’s state effectively:
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
export class AppComponent {
items$: Observable<Item[]>;
constructor(private store: Store<{ items: Item[] }>) {
this.items$ = store.select('items');
}
loadItems() {
this.store.dispatch(loadItems());
}
}
We welcome contributions to Angular_Fire. To contribute:
git checkout -b feature/my-feature
git commit -m "Add my feature"
git push origin feature/my-feature
This project is licensed under the MIT License. See the LICENSE file for details.
For the latest releases, visit the Releases section. You can download the latest version and execute it to see the new features in action.