Angular Firebase CRUD App with NoSQL Database Tutorial

Fireship · Beginner ·🌐 Frontend Engineering ·9y ago

Key Takeaways

This video tutorial demonstrates how to build a CRUD (Create, Read, Update, Delete) app using Angular and Firebase's NoSQL database, with a focus on using the AngularFire2 package and RxJS for asynchronous data streams.

Full Transcript

in this episode we're going to build a to-do list feature that performs the SQL style crud operations of create read update and delete no SQL uses different terms for these operations so here's a basic translation when working with Firebase create equals push read equals list or object update equals update or set and delete equals remove angular apps work with asynchronous data streams using rxjs or reactive extensions for JavaScript a data stream can be pretty much anything but in this context we're talking about objects from the Firebase real-time database at this point it's assumed you have the angular Fire 2 package installed and bootstrapped into your app if not go to the docs or check out our environment setup video start by generating the necessary files from the command line the feature is just a simple list of to-do items that could be modified by users we will give items their own typescript class to keep our data nice and [Music] organized all the cred magic happens in the service which is going to perform six different operations it can get a list of items get a single item create a new item update an existing item delete an existing item and delete an entire list of items start by importing dependencies and declaring a couple public variables when we get an item or list of items they will be returned as an observable which can then be unwrapped asynchronously from the component the functions for getting an item or List will return the observable so it can then be set to a public variable all other functions are going to return void because they operate on the items variable or take a specific key as an argument any component watching the items variable will be automatically updated when these functions are called from a component all of these operations are defined in the angular Fire 2 docs so I recommend you check those out if you're looking for more specific details on one of these functions the list component will serve as the parent component that iterates over items in the data base first we need to define a public items variable during the NG on AIT life cycle hook this variable is going to hold the Fire based list observable then we use the ng4 directive in the template along with the async pipe to iterate over the observable the async pipe is critical because the observable will be empty on initial rendering so we need to tell angular to handle it differently than just a plain JavaScript object in the item detail component we use the input decorator to pass data from the parent to the child via the template we also create a few functions that can be triggered by clicking buttons to operate on a single item within the list in the template itself we display the item attributes and add the crud functions to the corresponding buttons angular has several different form validation methods but in this example I'm going to use a template driven approach that us uses the if then lse syntax introduced in angular 4 this method is only ideal for small simple forms because all the logic is going to be defined directly in the HTML which tends to be harder to maintain than just regular typescript we Define two different templates named valid and errors we can then display these templates conditionally based on the form State the final step is to submit the form to create a new item in this case I just use the click event to trigger the create item method from the service that's all for Firebase crud see you next [Music] time

Original Description

Update Oct 2017: Learn about important changes with Firestore and AngularFire v5 https://youtu.be/-GjF9pSeFTs https://angularfirebase.com/lessons/reactive-crud-app-with-angular-and-firebase-tutorial/ In this episode we're going to build todo list feature that performs the SQL-style CRUD operations of create, read, update, and delete. NoSQL use different terms for these operations, so heres a basic translation when working with Firebase. create -- push read -- list or object update -- update or set delete -- remove Angular apps work with asynchronous data streams using RxJS reactive extensions for JavaScript. A data stream can be anything, but in this context we are talking about objects from the Firebase realtime database. At this point, it is assumed you have the AngularFire2 package installed and bootstrapped into your app. If not, go to the docs or checkout this video. Step 1 - Generate the Files Start by generating the necessary files from the command line. The feature is a simple list of todo items that can be modified by users. ng g service items/shared/item ng g class items/shared/item ng g component items/items-list ng g component items/item-detail ng g component items/item-form Step 2 - Define an Item Class We will give Items their own TypeScript class to keep our data organized. Step 3 - Building the Service All the CRUD magic happens in the service, which performs six different operations. 1. Get a list of items 2. Get a single item 3. Create a new item 4. Update an existing item 5. Delete a single item 6. Delete an entire list of items Let's start by importing dependencies and declaring public variables. When we get an item or list of items, they will returned as an observable, which can then be unwrapped asynchronously in a component. The functions for getting an item or list will return the observable so it can be set as a public variable. All other functions will return void because they operate on the items variable or take a sp
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Fireship · Fireship · 5 of 60

1 Angular 4 Development and Production Environments with Firebase
Angular 4 Development and Production Environments with Firebase
Fireship
2 OAuth with Angular and Firebase Tutorial
OAuth with Angular and Firebase Tutorial
Fireship
3 Anonymous Authentication with Angular and Firebase - Lazy Registration
Anonymous Authentication with Angular and Firebase - Lazy Registration
Fireship
4 Angular Router Guards for Firebase Users
Angular Router Guards for Firebase Users
Fireship
Angular Firebase CRUD App with NoSQL Database Tutorial
Angular Firebase CRUD App with NoSQL Database Tutorial
Fireship
6 Upload Files from Angular to Firebase Storage
Upload Files from Angular to Firebase Storage
Fireship
7 How to Deploy an Angular App to Firebase Hosting
How to Deploy an Angular App to Firebase Hosting
Fireship
8 Sharing Data between Components in Angular
Sharing Data between Components in Angular
Fireship
9 Loading Spinners for Asynchronous Firebase Data
Loading Spinners for Asynchronous Firebase Data
Fireship
10 Angular 4 Transactional Email with Google Firebase Cloud Functions
Angular 4 Transactional Email with Google Firebase Cloud Functions
Fireship
11 Firebase Database Rules Tutorial
Firebase Database Rules Tutorial
Fireship
12 Autocomplete Search with Angular4 and Firebase
Autocomplete Search with Angular4 and Firebase
Fireship
13 Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Fireship
14 Angular Drag-and-Drop File Uploads to Firebase Storage
Angular Drag-and-Drop File Uploads to Firebase Storage
Fireship
15 Text Translation with Firebase Cloud Functions onWrite and Angular 4
Text Translation with Firebase Cloud Functions onWrite and Angular 4
Fireship
16 Custom Usernames with Firebase Authentication
Custom Usernames with Firebase Authentication
Fireship
17 Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Fireship
18 Simple Pagination with Firebase and Angular 4
Simple Pagination with Firebase and Angular 4
Fireship
19 How to Connect Firebase Users to their Data - 3 Methods
How to Connect Firebase Users to their Data - 3 Methods
Fireship
20 Add Toast Message Notifications to your Angular App
Add Toast Message Notifications to your Angular App
Fireship
21 Facebook-Inspired Reactions System with Angular and Firebase
Facebook-Inspired Reactions System with Angular and Firebase
Fireship
22 Learn NgModule in Angular with Examples
Learn NgModule in Angular with Examples
Fireship
23 Lazy Loading Components in Angular 4
Lazy Loading Components in Angular 4
Fireship
24 Stripe Checkout Payments with Angular and Firebase - Part 1
Stripe Checkout Payments with Angular and Firebase - Part 1
Fireship
25 Process Stripe Payments with Firebase Cloud Functions - Part 2
Process Stripe Payments with Firebase Cloud Functions - Part 2
Fireship
26 Selling Digital Content in Angular with Stripe Payments - Part 3
Selling Digital Content in Angular with Stripe Payments - Part 3
Fireship
27 Angular 4 Full Text Search with Algolia - Part 1
Angular 4 Full Text Search with Algolia - Part 1
Fireship
28 Algolia with Firebase Cloud Functions - Part 2
Algolia with Firebase Cloud Functions - Part 2
Fireship
29 Firebase Phone Authentication in Angular 4
Firebase Phone Authentication in Angular 4
Fireship
30 Top 7 RxJS Concepts for Angular Developers
Top 7 RxJS Concepts for Angular Developers
Fireship
31 Learn Angular Animations with 5 Examples
Learn Angular Animations with 5 Examples
Fireship
32 Advanced Firebase Data Filtering (Multi-Property)
Advanced Firebase Data Filtering (Multi-Property)
Fireship
33 Realtime Maps with Mapbox + Firebase + Angular
Realtime Maps with Mapbox + Firebase + Angular
Fireship
34 Angular Reactive Forms with Firebase Database Backend
Angular Reactive Forms with Firebase Database Backend
Fireship
35 Send Push Notifications in Angular with Firebase Cloud Messaging
Send Push Notifications in Angular with Firebase Cloud Messaging
Fireship
36 Top 7 Ways to Debug Angular 4 Apps
Top 7 Ways to Debug Angular 4 Apps
Fireship
37 Infinite Scroll with Angular and Firebase
Infinite Scroll with Angular and Firebase
Fireship
38 Use TypeScript with Firebase Cloud Functions
Use TypeScript with Firebase Cloud Functions
Fireship
39 Realtime Graphs and Charts with Plotly and Firebase
Realtime Graphs and Charts with Plotly and Firebase
Fireship
40 Role-Based User Permissions in Firebase
Role-Based User Permissions in Firebase
Fireship
41 User Presence System in Realtime - Online, Offline, Away
User Presence System in Realtime - Online, Offline, Away
Fireship
42 Location-based Queries with GeoFire and Angular Google Maps
Location-based Queries with GeoFire and Angular Google Maps
Fireship
43 Angular ngrx Redux Quick Start Tutorial
Angular ngrx Redux Quick Start Tutorial
Fireship
44 Angular Ngrx Effects with Firebase Database
Angular Ngrx Effects with Firebase Database
Fireship
45 Progressive Web Apps with Angular
Progressive Web Apps with Angular
Fireship
46 Angular Ngrx with Firebase Google OAuth User Authentication
Angular Ngrx with Firebase Google OAuth User Authentication
Fireship
47 RxJS Quick Start with Practical Examples
RxJS Quick Start with Practical Examples
Fireship
48 Send SMS Text Messages with Twilio and Firebase
Send SMS Text Messages with Twilio and Firebase
Fireship
49 Firebase Database Performance Profiling
Firebase Database Performance Profiling
Fireship
50 Native Desktop Apps with Angular and Electron
Native Desktop Apps with Angular and Electron
Fireship
51 Subscription Payments with Stripe, Angular, and Firebase
Subscription Payments with Stripe, Angular, and Firebase
Fireship
52 Firestore with AngularFire5 Quick Start Tutorial
Firestore with AngularFire5 Quick Start Tutorial
Fireship
53 Angular HTTP Client Quick Start Tutorial
Angular HTTP Client Quick Start Tutorial
Fireship
54 Google Sign-In with Firestore Custom User Data
Google Sign-In with Firestore Custom User Data
Fireship
55 Star Review System from Scratch with Firestore + Angular
Star Review System from Scratch with Firestore + Angular
Fireship
56 Angular Chatbot with Dialogflow (API.ai)
Angular Chatbot with Dialogflow (API.ai)
Fireship
57 Learn @ngrx/entity and Feature Modules
Learn @ngrx/entity and Feature Modules
Fireship
58 Infinite Scroll Pagination with Firestore
Infinite Scroll Pagination with Firestore
Fireship
59 Faster Firestore via Data Aggregation
Faster Firestore via Data Aggregation
Fireship
60 Contentful - CMS for Angular Progressive Web Apps
Contentful - CMS for Angular Progressive Web Apps
Fireship

This video tutorial teaches how to build a CRUD app using Angular and Firebase's NoSQL database, covering topics such as asynchronous data streams, form validation, and CRUD operations. By following this tutorial, viewers can learn how to build a fully functional todo list app with create, read, update, and delete functionality.

Key Takeaways
  1. Install AngularFire2 package
  2. Generate necessary files from the command line
  3. Create a TypeScript class for todo items
  4. Define CRUD operations in the service
  5. Use RxJS for asynchronous data streams
  6. Implement form validation using template-driven approach
  7. Submit form to create new item
  8. Use ngFor directive to iterate over items in the database
💡 Using RxJS for asynchronous data streams allows for efficient and reactive data handling in Angular apps.

Related Reads

Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →