AndrewJBateman / angular-firebase-access

:clipboard: Angular with Firebase backend for CRUD operations on blog posts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⚑ Angular Firebase Access

  • Angular app using Firebase tools to access a Google Cloud Firestore
  • With a Google login or other auth setup it is possible to Create, Read, Update and Delete blog posts.
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

πŸ“„ Table of contents

πŸ“š General info

  • Allows access to create, read, update & delete Firebase posts

πŸ“· Screenshots

  • Example screenshot

πŸ“Ά Technologies

πŸ’Ύ Setup

  • Install dependencies using npm i
  • Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
  • Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.
  • Run ng update to update Angular

πŸ’» Code Examples

  • functions from post.service.ts to get all posts and a selected post.
getPosts = async (): Promise<any> => {
    let postsArray = [];
    const postCollectionRef = collection(db, "posts");
    const querySnapshot = await getDocs(query(postCollectionRef));
    querySnapshot.forEach(doc => {
      alert;
      postsArray.push({ id: doc.id, ...doc.data() });
      postsArray.sort((a, b) => b.published - a.published);
    });
    return postsArray;
  };

  showFullPost = (post: Post): void => {
    this.currentPost = post;
    this.router.navigate(["/post-detail"]);
  };
  

πŸ†’ Features

  • HTML template uses the Angular async pipe to subscribe to the posts Observable and to unsubscribe automatically in the onDestroy lifecycle, avoiding memory leaks.

πŸ“‹ Status & To-Do List

  • Status: Working
  • To-Do: Add tabs for posts categories

πŸ‘ Inspiration

πŸ“ License

  • This project is licensed under the terms of the MIT license.

βœ‰οΈ Contact

  • Repo created by ABateman, email: gomezbateman@yahoo.com

About

:clipboard: Angular with Firebase backend for CRUD operations on blog posts

License:MIT License


Languages

Language:TypeScript 65.8%Language:HTML 22.4%Language:JavaScript 6.0%Language:SCSS 5.9%