Activity 33: Angular Recipe Grid
This documentation outlines the structure and functionality of the Recipe Application, a simple application that manages recipe data. The application is built using TypeScript and Angular, and consists of the following components:
1. recipe.service.ts:
Purpose: The
recipe.service.ts
file houses the service responsible for managing recipe data. It provides methods for creating, reading, updating, and deleting (CRUD) recipes.Key Methods:
getRecipes()
: Retrieves all recipes from the data source.getRecipe(id: number)
: Retrieves a specific recipe by its ID.addRecipe(recipe: Recipe)
: Adds a new recipe to the data source.updateRecipe(recipe: Recipe)
: Updates an existing recipe in the data source.deleteRecipe(id: number)
: Deletes a recipe from the data source.
Example Usage:
import { Injectable } from '@angular/core';
import { Recipe } from '../models/library.mode';
@Injectable({
providedIn: 'root',
})
export class RecipeService {
private recipeList: Recipe[] = [
{
name: 'Adobo',
price: '250',
star: '★★★☆☆',
image:'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTEhMWFRUXGBcXFhgYFRgVFRcXFxcWFhkYGBgaHSggGBolGxcXIjEhJikrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGyslICYrLystLy8tLTItLS0tLS0tLSstLy0tLS0tLS0tLS0vLS8tLS0tLS0tLS0tLS0tLS0tLf/AABEIALYBFQMBIgACEQEDEQH/xAAbAAACAgMBAAAAAAAAAAAAAAAEBQMGAAECB//EADoQAAECBQMCBAQFBAICAgMAAAECEQADBCExBRJBUWETInGBBjKRoUKxweHwFCNS0WLxFYJyohYzkv/EABkBAAMBAQEAAAAAAAAAAAAAAAIDBAABBf/EACkRAAICAgICAgICAQUAAAAAAAABAhEDIRIxBEETIlFhMkKxFCMzUvD/2gAMAwEAAhEDEQA/APQxHEwx3A1QuDFg8+dC6onxlXOhNV1cC3R1KySpqIBWoZUfQdYFqarbc3jiWsMJsyyfwjJfowzCJZb0inHg9sY0fzXCSlWBz3iHV5SEI2qSfCcqO13A65v+0MqSchMtJAur5Rzct7cwv1KtKkTEqLkA2AuAHy3MQydz0epFVDZFRV8lUlNywHuW9I3TzjN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0zfnQXGCIzwNdMJeTvaPIzTqyBb0jZJHH2MX6q+DV/gV//SS4hZO+FahP4d3p+nSFOE12iiOWD6ZXtPTu4IPYZ/3DVNIWxcNxa8G0Xw5UbwfD2tcFWCe4BeLfI0ew3Bz2Fo5GGVvXX7OTy4ktq3+jzqZoxylBHcEpgil0+cnJfsxf6x6PL0n/AIGCE6Sf8QIYsM/7MS/Jj1FHmqqCY9klu2fp0iWTos1dvDUe5DfnHpKdKQMke0TiXLTw8GsP5AfksotJ8KzFfOrb6eZX1wIfUXwjKSBvBPdR/QMIempbAAiBdT7wxY4r0Kllk/ZLT0sqWGSkW7MPpG5lRAS58DTKscXMGLDlTIgVP4FzEMuWtWbCC5UoJxHHI6kZKkk3V9IKERgxvdAhkjxt4jeNgxjHUZGnjIxwnEbjIyMY3GRkZGMZG4yMjGMjHjIyMYjWkHMCzZLXBjIyMYGM8jMdpnRqMg0CyQTI34pjIyMcOhUGOhVqjIyOmOv60xv+tPSNRkajGGtPSOTXGMjIxjhVaqIlVSo1GRjlkap5iNU4xkZGMRLqWgRVeSWAjIyOM6iaVTqV8yvpBcqSlOBGRkA2GkEAx0DGRkcOmwY6eMjI6cNxkbjIxjYMajIyMY//2Q==',
},
{
name: 'Sinigang',
price: '300',
star: '★★★★☆',
image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTImaYPY_rHxSgGg1ogioWhOaNxeEp4TTNiIw&s',
},
{
name: 'Tinola',
price: '150',
star: '★☆☆☆☆',
image:
'https://panlasangpinoy.com/wp-content/uploads/2014/12/Tinola.jpg',
},
{
name: 'Kare-kare',
price: '250',
star: '★★☆☆☆',
image:'https://www.unileverfoodsolutions.com.ph/dam/global-ufs/mcos/SEA/calcmenu/recipes/PH-recipes/red-meats-&-red-meat-dishes/kare-kare/kare-kare-main.jpg',
},
{
name: 'Letchon Kawali',
price: '100',
star: '★★★☆☆',
image: 'https://www.sentro1771.com/ews/wp-content/uploads/2023/06/Lechon-Kawali_V2-scaled.jpg',
},
];
getRecipe() {
return this.recipeList;
}
}
2. recipe.model.ts:
Purpose: The
recipe.model.ts
file defines theRecipe
interface, which represents the structure of a recipe object. It defines the properties that each recipe object should have.Interface Definition:
export interface Recipe {
name: string;
price: string;
image: string;
star: string
}
3. recipe.component.ts:
Purpose: The
recipe.component.ts
file contains the logic for the Recipe component, which displays and interacts with recipe data. It handles user interactions, data binding, and communication with therecipe.service.ts
.Key Methods:
ngOnInit()
: Initializes the component, typically fetching initial recipe data from the service.addRecipe()
: Handles the addition of a new recipe.updateRecipe(recipe: Recipe)
: Handles the updating of an existing recipe.deleteRecipe(id: number)
: Handles the deletion of a recipe.
Example Usage:
import { Component } from '@angular/core';
import {Recipe} from '../../models/library.mode';
import { RecipeService } from '../../services/library.service';
import { OnInit } from '@angular/core';
@Component({
selector: 'app-recipe',
standalone: true,
imports: [],
templateUrl: './recipe.component.html',
styleUrl: './recipe.component.css'
})
export class RecipeComponent {
recipeList: Recipe[] = [];
constructor(private libraryService: RecipeService) {}
ngOnInit(): void {
this.recipeList = this.libraryService.getRecipe();
}
}
4. recipe.component.html:
Purpose: The
recipe.component.html
file defines the template for the Recipe component. It uses Angular's template syntax to display recipe data and provide user interaction elements.Template Structure:
<h1>Activity 33: Angular Recipe Grid</h1>
<main class="roboto-regular">
@for(book of recipeList; track $index){
<div class="book-card">
<div class="book-card__image__container">
<img class="book-card__image" [src]="book.image" />
</div>
<div class="book-card__details">
<p class="book-card__details__information roboto-bold">
Title: <span class="roboto-regular">{{ book.name }}</span>
</p>
<p class="book-card__details__information roboto-bold">
Price: <span class="roboto-regular">{{ book.price }}</span>
</p>
<p class="book-card__details__information roboto-bold">
Star: <span class="roboto-regular">{{ book.star }}</span>
</p>
<div class="button-container">
<button class="button-borrow roboto-medium"> Show Ingredient</button>
</div>
</div>
</div>
}
</main>
Key Elements:
*ngFor
: Iterates over therecipes
array to display each recipe.{{
recipe.name
}}
: Data binding to display the recipe name.(click)="deleteRecipe(
recipe.id
)"
: Event binding to trigger thedeleteRecipe()
method when the delete button is clicked.
Overall Application Flow:
The
recipe.component.ts
initializes and fetches recipe data from therecipe.service.ts
.The
recipe.component.html
displays the recipe data using Angular's template syntax.User interactions, such as adding, updating, or deleting recipes, are handled by the
recipe.component.ts
.The
recipe.component.ts
communicates with therecipe.service.ts
to perform CRUD operations on recipe data.
This documentation provides a basic overview of the Recipe Application. For a more detailed understanding, please refer to the source code files.
GITHUB LINK:https://github.com/jerome09232/acitivity33
FIREBASE LINK:https://acitivity33.web.app/
Subscribe to my newsletter
Read articles from Jerome Beriso directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by