Activity 23: Research Angular Services
What are Angular Services?
Reusable Logic: Services allow you to define functions and logic that can be shared across multiple components in your application. This avoids code duplication and promotes consistency.
Data Management: They can manage and store data, acting as a central repository for information that needs to be accessed from different parts of your application.
Communication: Services facilitate communication between components, allowing them to share data and events without direct dependencies.
Background Tasks: They can handle tasks that run in the background, such as fetching data from an API or performing calculations.
Key Benefits of Using Angular Services:
Modularity: Services break down your application into smaller, independent units, making it easier to understand, maintain, and test.
Testability: Services can be easily tested in isolation, improving the overall quality of your code.
Maintainability: By separating logic and data into services, you can make changes without impacting other parts of your application.
Reusability: Services can be reused across multiple projects, saving you time and effort.
Sure, here is the numbered list:
Student List
import { Component } from '@angular/core'; import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-studentlist', templateUrl: './studentlist.component.html', styleUrl: './studentlist.component.css' }) export class StudentlistComponent { studentLis: string[] = ["gerlie", "dao-ayan"]; item: string = ''; addItems() { this.studentLis.push(this.item); } deleteStudent(index: number) { this.studentLis.splice(index, 1); } }
Employee
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', })@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-employeelist', templateUrl: './employeelist.component.html', styleUrl: './employeelist.component.css' }) export class EmployeelistComponent { employerList: string[] = ["employer1", "employer2"]; item: string = ''; addItems() { this.employerList.push(this.item); } deleteEmployee(index: number) { this.employerList.splice(index, 1); } }
Fruit List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-fruit', templateUrl: './fruit.component.html', styleUrl: './fruit.component.css' }) export class FruitComponent { fruitLis: string[] = ["grapes", "dragonfruit", "cherry"]; item: string = ''; addItems() { this.fruitLis.push(this.item); } deleteFruit(index: number) { this.fruitLis.splice(index, 1); } }
Course List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-course', templateUrl: './course.component.html', styleUrl: './course.component.css' }) export class CourseComponent { courseLis: string[] = ["BSIT", "BSHM", "BSECUD"]; item: string = ''; addItems() { this.courseLis.push(this.item); } deleteCourse(index: number) { this.courseLis.splice(index, 1); } }
Book List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-book', templateUrl: './book.component.html', styleUrl: './book.component.css' }) export class BookComponent { bookLit: string[] = ["c++", "java", "html"]; item: string = ''; addItems() { this.bookLit.push(this.item); } deleteBook(index: number) { this.bookLit.splice(index, 1); } }
City List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-city', templateUrl: './city.component.html', styleUrl: './city.component.css' }) export class CityComponent { cityLis: string[] = ["spain", "america", "korea"]; item: string = ''; addItems() { this.cityLis.push(this.item); } deleteCity(index: number) { this.cityLis.splice(index, 1); } }
Movie List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-movie', templateUrl: './movie.component.html', styleUrl: './movie.component.css' }) export class MovieComponent { movieLis: string[] = ["shrek", "wrong turn"]; item: string = ''; addItems() { this.movieLis.push(this.item); } deleteMovie(index: number) { this.movieLis.splice(index, 1); } }
Car Model List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-car', templateUrl: './car.component.html', styleUrl: './car.component.css' }) export class CarComponent { carModelLis: string[] = ["Toyota", "Honda", "Mustang"]; item: string = ''; addItems() { this.carModelLis.push(this.item); } deleteCarModel(index: number) { this.carModelLis.splice(index, 1); } }
Product List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-product', templateUrl: './product.component.html', styleUrl: './product.component.css' }) export class ProductComponent { productLis: string[] = ["phone", "tablet", "headset"]; item: string = ''; addItems() { this.productLis.push(this.item); } deleteProduct(index: number) { this.productLis.splice(index, 1); } }
Subject List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-subject', templateUrl: './subject.component.html', styleUrl: './subject.component.css' }) export class SubjectComponent { subjectLis: string[] = ["filifino", "English", "Science"]; item: string = ''; addItems() { this.subjectLis.push(this.item); } deleteSubject(index: number) { this.subjectLis.splice(index, 1); } }
Country List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-country', templateUrl: './country.component.html', styleUrl: './country.component.css' }) export class CountryComponent { countryLis: string[] = ["north korea", "Canada"]; item: string = ''; addItems() { this.countryLis.push(this.item); } deleteCountry(index: number) { this.countryLis.splice(index, 1); } }
Sports List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-sport', templateUrl: './sport.component.html', styleUrl: './sport.component.css' }) export class SportComponent { sportsLis: string[] = ["tennis", "Volleyball"]; item: string = ''; addItems() { this.sportsLis.push(this.item); } deleteSport(index: number) { this.sportsLis.splice(index, 1); } }
Vegetable List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-vagetable', templateUrl: './vagetable.component.html', styleUrl: './vagetable.component.css' }) export class VagetableComponent { vegetableLis: string[] = ["Carrot"]; item: string = ''; addItems() { this.vegetableLis.push(this.item); } deleteVegetable(index: number) { this.vegetableLis.splice(index, 1); } }
Animal List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-animal', templateUrl: './animal.component.html', styleUrl: './animal.component.css' }) export class AnimalComponent { animalLis: string[] = ["Dog", "Cat"]; item: string = ''; addItems() { this.animalLis.push(this.item); } deleteAnimal(index: number) { this.animalLis.splice(index, 1); } }
Tool List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-tool', templateUrl: './tool.component.html', styleUrl: './tool.component.css' }) export class ToolComponent { toolLis: string[] = ["Hammer"]; item: string = ''; addItems() { this.toolLis.push(this.item); } deleteTool(index: number) { this.toolLis.splice(index, 1); } }
Language List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-laguage', templateUrl: './laguage.component.html', styleUrl: './laguage.component.css' }) export class LaguageComponent { languageLis: string[] = ["English"]; item: string = ''; addItems() { this.languageLis.push(this.item); } deleteLanguage(index: number) { this.languageLis.splice(index, 1); } }
Game List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-game', templateUrl: './game.component.html', styleUrl: './game.component.css' }) export class GameComponent { gameLis: string[] = [ "Fortnite"]; item: string = ''; addItems() { this.gameLis.push(this.item); } deleteGame(index: number) { this.gameLis.splice(index, 1); } }
Software List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-software', templateUrl: './software.component.html', styleUrl: './software.component.css' }) export class SoftwareComponent { software: string[] = [ "software1"]; item: string = ''; addItems() { this.software.push(this.item); } deleteGame(index: number) { this.software.splice(index, 1); } }
Phone Contact List
```plaintext import {Component, Injectable} from '@angular/core';
interface Contact { name: string; phoneNumber: string;
}@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-phone', templateUrl: './phone.component.html', styleUrl: './phone.component.css' }) export class PhoneComponent { contactLis: Contact[] = [ { name: "Gerlie Dao-ayan", phoneNumber: "09518942333" }, { name: "garl", phoneNumber: "09380798236" } ]; name: string = ''; phoneNumber: string = '';
addContact() { const newContact: Contact = { name: this.name, phoneNumber: this.phoneNumber }; this.contactLis.push(newContact); this.name = ''; this.phoneNumber = ''; }
deleteContact(index: number) { this.contactLis.splice(index, 1); } }

20. Music Playlist
```plaintext
import {Component, Injectable} from '@angular/core';
@Injectable({
providedIn: 'root',
})
@Component({
selector: 'app-music',
templateUrl: './music.component.html',
styleUrl: './music.component.css'
})
export class MusicComponent {
playlis: string[] = ["Bohemian Rhapsody", "Imagine", "Hotel California"];
newSong: string = '';
addSong() {
this.playlis.push(this.newSong);
this.newSong = ''; // Clear the input field
}
deleteSong(index: number) {
this.playlis.splice(index, 1);
}
}

Food Menu
import {Component, Injectable} from '@angular/core'; import {FormsModule} from "@angular/forms"; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-food', templateUrl: './food.component.html', styleUrl: './food.component.css' }) export class FoodComponent { menuItems: string[] = ["Burger", "Footlong", "Salad", "Spaghetti"]; newIte: string = ''; addMenuItem() { this.menuItems.push(this.newIte); this.newIte = ''; // Clear the input field } deleteMenuItem(index: number) { this.menuItems.splice(index, 1); } }
Grocery List
import {Component, Injectable} from '@angular/core'; import {FormsModule} from "@angular/forms"; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-grocery', templateUrl: './grocery.component.html', styleUrl: './grocery.component.css' }) export class GroceryComponent { groceryLis: string[] = ["Kimchi", "Paper", "Soda", "Cheese"]; newItem: string = ''; addItem() { this.groceryLis.push(this.newItem); this.newItem = ''; // Clear the input field } deleteItem(index: number) { this.groceryLis.splice(index, 1); } }
Classroom List
import {Component, Injectable} from '@angular/core'; @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-classroom', templateUrl: './classroom.component.html', styleUrl: './classroom.component.css' }) export class ClassroomComponent { studentLis: string[] = ["Arabella", "Abigail", "Dionisio", "Marvin"]; newStudent: string = ''; addStudent() { this.studentLis.push(this.newStudent); this.newStudent = ''; // Clear the input field } deleteStudent(index: number) { this.studentLis.splice(index, 1); } }
Inventory List
import {Component, Injectable} from '@angular/core'; interface InventoryItem { name: string; quantity: number; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-inventory', templateUrl: './inventory.component.html', styleUrl: './inventory.component.css' }) export class InventoryComponent { inventor: InventoryItem[] = [ { name: "T-Shirt", quantity: 20 }, { name: "Shoes", quantity: 10 } ]; newItem: string = ''; newQuantity: number = 0; addItem() { const newItem: InventoryItem = { name: this.newItem, quantity: this.newQuantity }; this.inventor.push(newItem); this.newItem = ''; this.newQuantity = 0; } deleteItem(index: number) { this.inventor.splice(index, 1); } }
Lecture List
import {Component, Injectable} from '@angular/core'; interface Lecture { topic: string; date: Date; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-lecture', templateUrl: './lecture.component.html', styleUrl: './lecture.component.css' }) export class LectureComponent { lectureLis: Lecture[] = [ { topic: "Introduction to Programming", date: new Date('2024-01-15') }, { topic: "Data Structures", date: new Date('2024-01-22') } ]; newLecture: string = ''; addLecture() { const newLecture: Lecture = { topic: this.newLecture, date: new Date() }; this.lectureLis.push(newLecture); this.newLecture = ''; } deleteLecture(index: number) { this.lectureLis.splice(index, 1); } }
Stationery List
import {Component, Injectable} from '@angular/core'; import {FormsModule} from "@angular/forms"; interface StationeryItem { name: string; quantity: number; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-stationery', templateUrl: './stationery.component.html', styleUrl: './stationery.component.css' }) export class StationeryComponent { stationeryLis: StationeryItem[] = [ { name: "Paper", quantity: 100 }, { name: "Staplers", quantity: 10 } ]; newItem: string = ''; newQuantity: number = 0; addItem() { const newItem: StationeryItem = { name: this.newItem, quantity: this.newQuantity }; this.stationeryLis.push(newItem); this.newItem = ''; this.newQuantity = 0; } deleteItem(index: number) { this.stationeryLis.splice(index, 1); } }
Flower List
import {Component, Injectable} from '@angular/core'; interface Flower { name: string; quantity: number; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-flower', templateUrl: './flower.component.html', styleUrl: './flower.component.css' }) export class FlowerComponent { flowerLis: Flower[] = [ { name: "Sunflower", quantity: 50 }, { name: "Rose", quantity: 20 }, { name: "Hydrangeas", quantity: 15 } ]; newFlower: string = ''; newQuantity: number = 0; addFlower() { const newFlower: Flower = { name: this.newFlower, quantity: this.newQuantity }; this.flowerLis.push(newFlower); this.newFlower = ''; this.newQuantity = 0; } deleteFlower(index: number) { this.flowerLis.splice(index, 1); } }
Destination List
import {Component, Injectable} from '@angular/core'; interface Destination { name: string; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-destination', templateUrl: './destination.component.html', styleUrl: './destination.component.css' }) export class DestinationComponent { destinationLis: Destination[] = [ { name: "Rome" }, { name: "Tokyo" }, { name: "Paris" } ]; newDestination: string = ''; addDestination() { const newDestination: Destination = { name: this.newDestination }; this.destinationLis.push(newDestination); this.newDestination = ''; } deleteDestination(index: number) { this.destinationLis.splice(index, 1); } }
Laptop List
import {Component, Injectable} from '@angular/core'; interface Laptop { model: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-laptop', templateUrl: './laptop.component.html', styleUrl: './laptop.component.css' }) export class LaptopComponent { laptopLis: Laptop[] = [ { model: "MacBook Pro 16" }, { model: "Lenovo ThinkPad X1 Carbon" } ]; newLaptop: string = ''; addLaptop() { const newLaptop: Laptop = { model: this.newLaptop }; this.laptopLis.push(newLaptop); this.newLaptop = ''; } deleteLaptop(index: number) { this.laptopLis.splice(index, 1); } }
Laptop Specifications List
import {Component, Injectable} from '@angular/core'; import {FormsModule} from "@angular/forms"; interface LaptopSpec { model: string; processor: string; ram: number; storage: number; screenSize: number; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-laptopspecifications', templateUrl: './laptopspecifications.component.html', styleUrl: './laptopspecifications.component.css' }) export class LaptopspecificationsComponent { laptopSpecsLis: LaptopSpec[] = [ { model: "MacBook Pro 16", processor: "Apple M2 Pro", ram: 16, storage: 512, screenSize: 16.2 }, { model: "Dell XPS 13", processor: "Intel Core i7-1360P", ram: 16, storage: 512, screenSize: 13.4 }, { model: "Lenovo ThinkPad X1 Carbon", processor: "Intel Core i7-1360P", ram: 16, storage: 512, screenSize: 14 } ]; newModel: string = ''; newProcessor: string = ''; newRam: number = 0; newStorage: number = 0; newScreenSize: number = 0; addLaptop() { const newLaptop: LaptopSpec = { model: this.newModel, processor: this.newProcessor, ram: this.newRam, storage: this.newStorage, screenSize: this.newScreenSize }; this.laptopSpecsLis.push(newLaptop); this.newModel = ''; this.newProcessor = ''; this.newRam = 0; this.newStorage = 0; this.newScreenSize = 0; } deleteLaptop(index: number) { this.laptopSpecsLis.splice(index, 1); } }
Computer Hardware List
import {Component, Injectable} from '@angular/core'; import {FormsModule} from "@angular/forms"; interface HardwareComponent { name: string; quantity: number; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-computerhardware', templateUrl: './computerhardware.component.html', styleUrl: './computerhardware.component.css' }) export class ComputerhardwareComponent { hardwareLis: HardwareComponent[] = [ { name: "RAM", quantity: 5 }, { name: "CPU", quantity: 10 }, { name: "Hard Drive", quantity: 8 } ]; newComponent: string = ''; newQuantity: number = 0; addComponent() { const newComponent: HardwareComponent = { name: this.newComponent, quantity: this.newQuantity }; this.hardwareLis.push(newComponent); this.newComponent = ''; this.newQuantity = 0; } deleteComponent(index: number) { this.hardwareLis.splice(index, 1); } }
Mobile App List
import {Component, Injectable} from '@angular/core'; interface App { name: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-mobileapp', templateUrl: './mobileapp.component.html', styleUrl: './mobileapp.component.css' }) export class MobileappComponent { appLis: App[] = [ { name: "Instagram" }, { name: "WhatsApp" }, ]; newApp: string = ''; addApp() { const newApp: App = { name: this.newApp }; this.appLis.push(newApp); this.newApp = ''; } deleteApp(index: number) { this.appLis.splice(index, 1); } }
Video List
import {Component, Injectable} from '@angular/core'; interface Video { title: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-video', templateUrl: './video.component.html', styleUrl: './video.component.css' }) export class VideoComponent { videoLis: Video[] = [ { title: "The Dark Knight" }, { title: "Pulp Fiction" } ]; newVideoTitle: string = ''; addVideo() { const newVideo: Video = { title: this.newVideoTitle }; this.videoLis.push(newVideo); this.newVideoTitle = ''; } deleteVideo(index: number) { this.videoLis.splice(index, 1); } }
TV Show List
import {Component, Injectable} from '@angular/core'; interface TVShow { name: string; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-tvshow', templateUrl: './tvshow.component.html', styleUrl: './tvshow.component.css' }) export class TvshowComponent { showLis: TVShow[] = [ { name: "Stranger Things" }, { name: "Game of Thrones" } ]; newShow: string = ''; addShow() { const newShow: TVShow = { name: this.newShow }; this.showLis.push(newShow); this.newShow = ''; } deleteShow(index: number) { this.showLis.splice(index, 1); } }
Furniture List
import {Component, Injectable} from '@angular/core'; interface Furniture { name: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-furniture', templateUrl: './furniture.component.html', styleUrl: './furniture.component.css' }) export class FurnitureComponent { furnitureLis: Furniture[] = [ { name: "Sofa" }, { name: "Chair" } ]; newFurniture: string = ''; addFurniture() { const newFurniture: Furniture = { name: this.newFurniture }; this.furnitureLis.push(newFurniture); this.newFurniture = ''; } deleteFurniture(index: number) { this.furnitureLis.splice(index, 1); } }
Accessory List
import {Component, Injectable} from '@angular/core'; interface Accessory { name: string; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-accessory', templateUrl: './accessory.component.html', styleUrl: './accessory.component.css' }) export class AccessoryComponent { accessoryLis: Accessory[] = [ { name: "Charger" }, { name: "Privacy Protector" }, { name: "Headphones" } ]; newAccessory: string = ''; addAccessory() { const newAccessory: Accessory = { name: this.newAccessory }; this.accessoryLis.push(newAccessory); this.newAccessory = ''; } deleteAccessory(index: number) { this.accessoryLis.splice(index, 1); } }
Building List
import {Component, Injectable} from '@angular/core'; interface Building { name: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-building', templateUrl: './building.component.html', styleUrl: './building.component.css' }) export class BuildingComponent { buildingLis: Building[] = [ { name: "Main Building" }, { name: "Science Hall" } ]; newBuilding: string = ''; addBuilding() { const newBuilding: Building = { name: this.newBuilding }; this.buildingLis.push(newBuilding); this.newBuilding = ''; } deleteBuilding(index: number) { this.buildingLis.splice(index, 1); } }
Painting List
import {Component, Injectable} from '@angular/core'; interface Painting { title: string; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-painting', templateUrl: './painting.component.html', styleUrl: './painting.component.css' }) export class PaintingComponent { paintingLis: Painting[] = [ { title: "The Starry Night" }, { title: "Girl with a Pearl Earring" } ]; newPainting: string = ''; addPainting() { const newPainting: Painting = { title: this.newPainting }; this.paintingLis.push(newPainting); this.newPainting = ''; } deletePainting(index: number) { this.paintingLis.splice(index, 1); } }
Artist List
import {Component, Injectable} from '@angular/core'; interface Artist { name: string; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-artist', templateUrl: './artist.component.html', styleUrl: './artist.component.css' }) export class ArtistComponent { artistLis: Artist[] = [ { name: "Leonardo de caprio" }, { name: "Natalie Portman" } ]; newArtist: string = ''; addArtist() { const newArtist: Artist = { name: this.newArtist }; this.artistLis.push(newArtist); this.newArtist = ''; } deleteArtist(index: number) { this.artistLis.splice(index, 1); } }
Composer List
import {Component, Injectable} from '@angular/core'; interface Composer { name: string; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-composer', templateUrl: './composer.component.html', styleUrl: './composer.component.css' }) export class ComposerComponent { composerLis: Composer[] = [ { name: "Ludwig van Beethoven" }, { name: "Johann Sebastian Bach" } ]; newComposer: string = ''; addComposer() { const newComposer: Composer = { name: this.newComposer }; this.composerLis.push(newComposer); this.newComposer = ''; } deleteComposer(index: number) { this.composerLis.splice(index, 1); } }
Podcast List
import {Component, Injectable} from '@angular/core'; interface PodcastEpisode { title: string; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-podcast', templateUrl: './podcast.component.html', styleUrl: './podcast.component.css' }) export class PodcastComponent { episodeLis: PodcastEpisode[] = [ { title: "Episode 2: The Big Reveal" }, { title: "Episode 3: The Twist" } ]; newEpisodeTitle: string = ''; addEpisode() { const newEpisode: PodcastEpisode = { title: this.newEpisodeTitle }; this.episodeLis.push(newEpisode); this.newEpisodeTitle = ''; } deleteEpisode(index: number) { this.episodeLis.splice(index, 1); } }
Exercise List
import {Component, Injectable} from '@angular/core'; interface Exercise { name: string; sets: number; reps: number; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-exercise', templateUrl: './exercise.component.html', styleUrl: './exercise.component.css' }) export class ExerciseComponent { exerciseLis: Exercise[] = [ { name: "Push-ups", sets: 3, reps: 10 }, { name: "Pull-ups", sets: 3, reps: 8 } ]; newExercise: string = ''; newSets: number = 0; newReps: number = 0; addExercise() { const newExercise: Exercise = { name: this.newExercise, sets: this.newSets, reps: this.newReps }; this.exerciseLis.push(newExercise); this.newExercise = ''; this.newSets = 0; this.newReps = 0; } deleteExercise(index: number) { this.exerciseLis.splice(index, 1); } }
Meal Plan List
import {Component, Injectable} from '@angular/core'; interface Meal { name: string; day: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-mealplan', templateUrl: './mealplan.component.html', styleUrl: './mealplan.component.css' }) export class MealplanComponent { mealPla: Meal[] = [ { name: "Breakfast Burrito", day: "Monday" }, { name: "Pasta with Veggies", day: "Wednesday" } ]; newMeal: string = ''; newDay: string = ''; days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]; addMeal() { const newMeal: Meal = { name: this.newMeal, day: this.newDay }; this.mealPla.push(newMeal); this.newMeal = ''; this.newDay = ''; } deleteMeal(index: number) { this.mealPla.splice(index, 1); } }
Budget List
import {Component, Injectable} from '@angular/core'; interface BudgetItem { name: string; cost: number; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-budget', templateUrl: './budget.component.html', styleUrl: './budget.component.css' }) export class BudgetComponent { budgetItem: BudgetItem[] = [ { name: "Software", cost: 500 }, ]; newItem: string = ''; newCost: number = 0; addItem() { const newItem: BudgetItem = { name: this.newItem, cost: this.newCost }; this.budgetItem.push(newItem); this.newItem = ''; this.newCost = 0; } deleteItem(index: number) { this.budgetItem.splice(index, 1); } getTotalCost(): number { return this.budgetItem.reduce((total, item) => total + item.cost, 0); } }
Presentation List
import {Component, Injectable} from '@angular/core'; interface PresentationTopic { name: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-presentation', templateUrl: './presentation.component.html', styleUrl: './presentation.component.css' }) export class PresentationComponent { topicLis: PresentationTopic[] = [ { name: "Sustainable Living Practices" }, { name: "The History of Music" } ]; newTopic: string = ''; addTopic() { const newTopic: PresentationTopic = { name: this.newTopic }; this.topicLis.push(newTopic); this.newTopic = ''; } deleteTopic(index: number) { this.topicLis.splice(index, 1); } }
Tour List
import {Component, Injectable} from '@angular/core'; interface TourDate { city: string; date: Date; } @Injectable({ providedIn: 'root', }) @Component({ selector: 'app-tour', templateUrl: './tour.component.html', styleUrl: './tour.component.css' }) export class TourComponent { tourDate: TourDate[] = [ { city: "Los Angeles", date: new Date('2024-03-22') }, { city: "Chicago", date: new Date('2024-03-29') } ]; newCity: string = ''; newDate: Date = new Date(); addTourDate() { const newTourDate: TourDate = { city: this.newCity, date: this.newDate }; this.tourDate.push(newTourDate); this.newCity = ''; this.newDate = new Date(); } deleteTourDate(index: number) { this.tourDate.splice(index, 1); } }
Event List
import {Component, Injectable} from '@angular/core'; interface Event { name: string; date: Date; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-event', templateUrl: './event.component.html', styleUrl: './event.component.css' }) export class EventComponent { eventLis: Event[] = [ { name: "Tech Conference", date: new Date('2024-09-20') }, { name: "Art Exhibition", date: new Date('2024-11-05') } ]; newEvent: string = ''; newDate: Date = new Date(); addEvent() { const newEvent: Event = { name: this.newEvent, date: this.newDate }; this.eventLis.push(newEvent); this.newEvent = ''; this.newDate = new Date(); } deleteEvent(index: number) { this.eventLis.splice(index, 1); } }
Developer Tools List
import {Component, Injectable} from '@angular/core'; interface DevTool { name: string; category: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-developer', templateUrl: './developer.component.html', styleUrl: './developer.component.css' }) export class DeveloperComponent { devToolsLis: DevTool[] = [ { name: "Visual Studio Code", category: "Code Editor" }, { name: "Git", category: "Version Control" }, ]; newTool: string = ''; newCategory: string = ''; addTool() { const newTool: DevTool = { name: this.newTool, category: this.newCategory }; this.devToolsLis.push(newTool); this.newTool = ''; this.newCategory = ''; } deleteTool(index: number) { this.devToolsLis.splice(index, 1); } }
Framework List
import {Component, Injectable} from '@angular/core'; interface Framework { name: string; type: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-framework', templateUrl: './framework.component.html', styleUrl: './framework.component.css' }) export class FrameworkComponent { frameworkLis: Framework[] = [ { name: "Angular", type: "Front-End" }, { name: "Vue.js", type: "Front-End" }, { name: "Express.js", type: "Back-End" }, { name: "Django", type: "Back-End" } ]; newFramework: string = ''; newType: string = ''; frameworkTypes = ["Front-End", "Back-End", "Full-Stack"]; addFramework() { const newFramework: Framework = { name: this.newFramework, type: this.newType }; this.frameworkLis.push(newFramework); this.newFramework = ''; this.newType = ''; } deleteFramework(index: number) { this.frameworkLis.splice(index, 1); } }
Library List
import {Component, Injectable} from '@angular/core'; interface Library { name: string; }@Injectable({ providedIn: 'root', }) @Component({ selector: 'app-library', templateUrl: './library.component.html', styleUrl: './library.component.css' }) export class LibraryComponent { libraryLis: Library[] = [ { name: "lodash" }, { name: "axios" } ]; newLibrary: string = ''; addLibrary() { const newLibrary: Library = { name: this.newLibrary }; this.libraryLis.push(newLibrary); this.newLibrary = ''; } deleteLibrary(index: number) { this.libraryLis.splice(index, 1); } }
GITHUB LINK:
https://github.com/Gerliedao-ayan/Activity-15.git
FIREBASE LINK:
