Skip to main content

Command Palette

Search for a command to run...

Angular Services

Updated
•18 min read•View as Markdown
Angular Services

Angular services are singleton objects that provide reusable functionalities, such as data fetching or business logic, to components across the application. They help keep the code modular and organized by separating logic from the components. Services are typically injected into components via Angular's dependency injection system.

In Angular, services play a crucial role in building efficient, maintainable, and scalable applications. They allow you to extract common logic and functionalities, such as data access, API interactions, or business calculations, and share them across multiple components. This helps keep your components lean and focused on their specific tasks, promoting clean separation of concerns. By using Angular's dependency injection, services can be effortlessly injected wherever needed, ensuring consistency and reducing code duplication.

Here’s the example of services I made using the 50 components activity.

1. STUDENT LIST COMPONENT and SERVICES

//studentlist.component.ts

export class StudentlistComponent implements OnInit {
  studentList: string[] = [];
  studentName: string = '';

  constructor(private studentListService: StudentlistService) {
  }

  ngOnInit() {
    this.studentList = this.studentListService.getStudents();
  }

  // TODO ADD DATA
  addStudent() {
    console.log(this.studentList);
    this.studentListService.addStudent(this.studentName);
    this.studentName = '';
  }
}

//studentlist.service.ts

export class StudentlistService {
  private students: string[] = [];

  constructor() { }

  // TODO GET
  getStudents(): string[] {
    return this.students;
  }

  // TODO ADD
  addStudent(student: string): void {
    this.students.push(student);
  }

Sample Output:

2. EMPLOYEE LIST COMPONENT AND SERVICES

//employeelist.component.ts
export class EmployeelistComponent {
  employeeList: string[] = [];
  employeeName: string = '';

  constructor(private employeeListService: EmployeeService) {
  }

  ngOnInit() {
    this.employeeList = this.employeeListService.getEmployee();
  }

  // TODO ADD DATA
  addEmployee() {
    console.log(this.employeeList);
    this.employeeListService.addEmployee(this.employeeName);
    this.employeeName = '';
  }

}


//employeelist.service.ts
export class EmployeeService {
  private employee: string[] = [];

  constructor() { }

  // TODO GET
  getEmployee(): string[] {
    return this.employee;
  }

  // TODO ADD
  addEmployee(employee: string): void {
    this.employee.push(employee);
  }
}

3. FRUIT LIST COMPONENT AND SERVICES

//fruitlist.component.ts
export class FruitlistComponent {
  fruitList: string[] = [];
  fruitName: string = '';

  constructor(private fruitListService: FruitlistService) {
  }

  ngOnInit() {
    this.fruitList = this.fruitListService.getFruit();
  }

  // TODO ADD DATA
  addFruit() {
    console.log(this.fruitList);
    this.fruitListService.addFruit(this.fruitName);
    this.fruitName = '';
  }

}

//fruitlist.service.ts
export class FruitlistService {
  private fruits: string[] = [];

  constructor() { }

  // TODO GET
  getFruit(): string[] {
    return this.fruits;
  }

  // TODO ADD
  addFruit(fruit: string): void {
    this.fruits.push(fruit);
  }
}

4. COURSE LIST COMPONENT AND SERVICES

//courselist.component.ts
export class CourselistComponent {
  courseList: string[] = [];
  courseName: string = '';

  constructor(private courseListService: CourselistService) {
  }

  ngOnInit() {
    this.courseList = this.courseListService.getCourse();
  }

  // TODO ADD DATA
  addCourse() {
    console.log(this.courseList);
    this.courseListService.addCourse(this.courseName);
    this.courseName = '';
  }


}

//courselist.service.ts
export class CourselistService {
  private courses: string[] = [];

  constructor() { }

  // TODO GET
  getCourse(): string[] {
    return this.courses;
  }

  // TODO ADD
  addCourse(course: string): void {
    this.courses.push(course);
  }
}

5. BOOK LIST COMPONENT AND SERVICES

//booklist.component.ts
export class BooklistComponent {

  bookList: string[] = [];
  bookName: string = '';

  constructor(private bookListService: BooklistService) {
  }

  ngOnInit() {
    this.bookList = this.bookListService.getBooks();
  }

  // TODO ADD DATA
  addBook() {
    console.log(this.bookList);
    this.bookListService.addBook(this.bookName);
    this.bookName = '';
  }
}
//booklist.service.ts
export class BooklistService {
  private books: string[] = [];

  constructor() { }

  // TODO GET
  getBooks(): string[] {
    return this.books;
  }

  // TODO ADD
  addBook(book: string): void {
    this.books.push(book);
  }
}

6. CITY LIST COMPONENT AND SERVICES

//citylist.component.ts
export class CitylistComponent {
  cityList: string[] = [];
  cityName: string = '';

  constructor(private cityListService: CitylistService) {
  }

  ngOnInit() {
    this.cityList = this.cityListService.getCities();
  }

  // TODO ADD DATA
  addCity() {
    console.log(this.cityList);
    this.cityListService.addCity(this.cityName);
    this.cityName = '';
  }
}

//citylist.service.ts
export class CitylistService {
  private cities: string[] = [];

  constructor() { }

  // TODO GET
  getCities(): string[] {
    return this.cities;
  }

  // TODO ADD
  addCity(city: string): void {
    this.cities.push(city);
  }
}

7. MOVIE LIST COMPONENT AND SERVICES

//movielist.component.ts
export class MovielistComponent {
  movieList: string[] = [];
  movieName: string = '';

  constructor(private movieListService: MovielistService) {
  }

  ngOnInit() {
    this.movieList = this.movieListService.getMovies();
  }

  // TODO ADD DATA
  addMovie() {
    console.log(this.movieList);
    this.movieListService.addMovie(this.movieName);
    this.movieName = '';
  }
}

//movielist.service.ts
export class MovielistService {
  private movies: string[] = [];

  constructor() { }

  // TODO GET
  getMovies(): string[] {
    return this.movies;
  }

  // TODO ADD
  addMovie(movie: string): void {
    this.movies.push(movie);
  }
}

8. CAR MODEL LIST COMPONENT AND SERVICES

//carmodellist.component.ts
 export class CarmodellistComponent {
  carModelList: string[] = [];
  carModelName: string = '';

  constructor(private carModelListService: CarmodellistService) {
  }

  ngOnInit() {
    this.carModelList = this.carModelListService.getCarModels();
  }

  // TODO ADD DATA
  addCarModel() {
    console.log(this.carModelList);
    this.carModelListService.addCarModel(this.carModelName);
    this.carModelName = '';
  }
}

//carmodellist.service.ts
export class CarmodellistService {
  private carModels: string[] = [];

  constructor() { }

  // TODO GET
  getCarModels(): string[] {
    return this.carModels;
  }

  // TODO ADD
  addCarModel(car: string): void {
    this.carModels.push(car);
  }
}

9. PRODUCT LIST COMPONENT AND SERVICES

//productlist.component.ts
export class ProductlistComponent {
  productList: string[] = [];
  productName: string = '';

  constructor(private productListService: ProductlistService) {
  }

  ngOnInit() {
    this.productList = this.productListService.getProducts();
  }

  // TODO ADD DATA
  addProduct() {
    console.log(this.productList);
    this.productListService.addProduct(this.productName);
    this.productName = '';
  }

}

//productlist.service.ts
export class ProductlistService {
  private products: string[] = [];

  constructor() { }

  // TODO GET
  getProducts(): string[] {
    return this.products;
  }

  // TODO ADD
  addProduct(product: string): void {
    this.products.push(product);
  }
}
  1. SUBJECT LIST COMPONENT AND SERVICES
//subjectlist.component.ts
export class SubjectlistComponent {
  subjectList: string[] = [];
  subjectName: string = '';

  constructor(private subjectListService: SubjectlistService) {
  }

  ngOnInit() {
    this.subjectList = this.subjectListService.getSubjects();
  }

  // TODO ADD DATA
  addSubject() {
    console.log(this.subjectList);
    this.subjectListService.addSubject(this.subjectName);
    this.subjectName = '';
  }

}

//subjectlist.service.ts
export class SubjectlistService {
  private subjects: string[] = [];

  constructor() { }

  // TODO GET
  getSubjects(): string[] {
    return this.subjects;
  }

  // TODO ADD
  addSubject(subject: string): void {
    this.subjects.push(subject);
  }
}

11. COUNTRY LIST COMPONENT AND SERVICES

//countrylist.component.ts
export class CountrylistComponent {
  countryList: string[] = [];
  countryName: string = '';

  constructor(private countryListService: CountrylistService) {
  }

  ngOnInit() {
    this.countryList = this.countryListService.getCountries();
  }

  // TODO ADD DATA
  addCountry() {
    console.log(this.countryList);
    this.countryListService.addCountry(this.countryName);
    this.countryName = '';
  }

}
//countrylist.service.ts
export class CountrylistService {
  private countries: string[] = [];

  constructor() { }

  // TODO GET
  getCountries(): string[] {
    return this.countries;
  }

  // TODO ADD
  addCountry(country: string): void {
    this.countries.push(country);
  }
}

12. SPORT LIST COMPONENT AND SERVICES

//sportlist.component.ts
export class SportslistComponent {
  sportsList: string[] = [];
  sportsName: string = '';

  constructor(private sportsListService: SportlistService) {
  }

  ngOnInit() {
    this.sportsList = this.sportsListService.getSports();
  }

  // TODO ADD DATA
  addSport() {
    console.log(this.sportsList);
    this.sportsListService.addSport(this.sportsName);
    this.sportsName = '';
  }
}


//sportlist.service.ts
export class SportlistService {
  private sports: string[] = [];

  constructor() { }

  // TODO GET
  getSports(): string[] {
    return this.sports;
  }

  // TODO ADD
  addSport(sport: string): void {
    this.sports.push(sport);
  }
}
  1. VEGETABLE LIST COMPONENT AND SERVICES
//vegetablelist.component.ts
export class VegetablelistComponent {
  vegetableList: string[] = [];
  vegetableName: string = '';

  constructor(private vegetableListService: VegetablelistService) {
  }

  ngOnInit() {
    this.vegetableList = this.vegetableListService.getVegetables();
  }

  // TODO ADD DATA
  addVegetable() {
    console.log(this.vegetableList);
    this.vegetableListService.addVegetable(this.vegetableName);
    this.vegetableName = '';
  }

}

//vegetablelist.service.ts
export class VegetablelistService {
  private vegetables: string[] = [];

  constructor() { }

  // TODO GET
  getVegetables(): string[] {
    return this.vegetables;
  }

  // TODO ADD
  addVegetable(vegetable: string): void {
    this.vegetables.push(vegetable);
  }
}

14. ANIMAL LIST COMPONENT AND SERVICES

//animallist.component.ts
export class AnimallistComponent {

  animalList: string[] = [];
  animalName: string = '';

  constructor(private animalListService: AnimallistService) {
  }

  ngOnInit() {
    this.animalList = this.animalListService.getAnimals();
  }

  // TODO ADD DATA
  addAnimal() {
    console.log(this.animalList);
    this.animalListService.addAnimal(this.animalName);
    this.animalName = '';
  }

}
//animallist.service.ts
export class AnimallistService {
  private animals: string[] = [];

  constructor() { }

  // TODO GET
  getAnimals(): string[] {
    return this.animals;
  }

  // TODO ADD
  addAnimal(animal: string): void {
    this.animals.push(animal);
  }
}

15. TOOL LIST COMPONENT AND SERVICES

//toollist.component.ts
export class ToollistComponent {
  toolList: string[] = [];
  toolName: string = '';

  constructor(private toolListService:ToollistService) {
  }

  ngOnInit() {
    this.toolList = this.toolListService.getTools();
  }

  // TODO ADD DATA
  addTool() {
    console.log(this.toolList);
    this.toolListService.addTool(this.toolName);
    this.toolName = '';
  }

}

//toollist.service.ts
export class ToollistService {

  private tools: string[] = [];

  constructor() { }

  // TODO GET
  getTools(): string[] {
    return this.tools;
  }

  // TODO ADD
  addTool(tool: string): void {
    this.tools.push(tool);
  }
}

16. LANGUAGE LIST COMPONENT AND SERVICES

//languagelist.component.ts
export class LanguagelistComponent {
  languageList: string[] = [];
  languageName: string = '';

  constructor(private languageListService: LanguagelistService) {
  }

  ngOnInit() {
    this.languageList = this.languageListService.getLanguages();
  }

  // TODO ADD DATA
  addLanguage() {
    console.log(this.languageList);
    this.languageListService.addLanguage(this.languageName);
    this.languageName = '';
  }

}

//languagelist.service.ts
export class LanguagelistService {
  private languages: string[] = [];

  constructor() { }

  // TODO GET
  getLanguages(): string[] {
    return this.languages;
  }

  // TODO ADD
  addLanguage(language: string): void {
    this.languages.push(language);
  }
}

17. GAME LIST COMPONENT AND SERVICES

//gamelist.component.ts
export class GamelistComponent {
  gameList: string[] = [];
  gameName: string = '';

  constructor(private gameListService: GamelistService) {
  }

  ngOnInit() {
    this.gameList = this.gameListService.getGames();
  }

  // TODO ADD DATA
  addGame() {
    console.log(this.gameList);
    this.gameListService.addGame(this.gameName);
    this.gameName = '';
  }

}
//gamelist.service.ts
export class GamelistService {
  private games: string[] = [];

  constructor() { }

  // TODO GET
  getGames(): string[] {
    return this.games;
  }

  // TODO ADD
  addGame(game: string): void {
    this.games.push(game);
  }
}

18. SOFTWARE LIST COMPONENT AND SERVICES

//softwarelist.component.ts
export class SoftwarelistComponent {
  softwareList: string[] = [];
  softwareName: string = '';

  constructor(private softwareListService: SoftwarelistService) {
  }

  ngOnInit() {
    this.softwareList = this.softwareListService.getSoftwares();
  }

  // TODO ADD DATA
  addSoftware() {
    console.log(this.softwareList);
    this.softwareListService.addSoftware(this.softwareName);
    this.softwareName = '';
  }

}
//softwarelist.service.ts
export class SoftwarelistService {
  private softwares: string[] = [];

  constructor() { }

  // TODO GET
  getSoftwares(): string[] {
    return this.softwares;
  }

  // TODO ADD
  addSoftware(software: string): void {
    this.softwares.push(software);
  }
}

19. CONTACT LIST COMPONENT AND SERVICES

//contactlist.component.ts
export class PhonecontactlistComponent {
  contactList: string[] = [];
  contactName: string = '';

  constructor(private contactListService: ContactlistService) {
  }

  ngOnInit() {
    this.contactList = this.contactListService.getContacts();
  }

  // TODO ADD DATA
  addContact() {
    console.log(this.contactList);
    this.contactListService.addContact(this.contactName);
    this.contactName = '';
  }

}

//contactlist.service.ts
export class ContactlistService {
  private contacts: string[] = [];

  constructor() { }

  // TODO GET
  getContacts(): string[] {
    return this.contacts;
  }

  // TODO ADD
  addContact(contact: string): void {
    this.contacts.push(contact);
  }
}

20. MUSIC LIST COMPONENT AND SERVICES

//musiclist.component.ts
export class MusicplaylistsComponent {
  musicList: string[] = [];
  musicName: string = '';

  constructor(private musicListService: MusiclistService) {
  }

  ngOnInit() {
    this.musicList = this.musicListService.getMusics();
  }

  // TODO ADD DATA
  addMusic() {
    console.log(this.musicList);
    this.musicListService.addMusic(this.musicName);
    this.musicName = '';
  }

}
//musiclist.service.ts
export class MusiclistService {
  private musics: string[] = [];

  constructor() { }

  // TODO GET
  getMusics(): string[] {
    return this.musics;
  }

  // TODO ADD
  addMusic(music: string): void {
    this.musics.push(music);
  }
}

21. MENU LIST COMPONENT AND SERVICES

//menulist.component.ts
export class FoodmenulistComponent {
  menuList: string[] = [];
  menuName: string = '';

  constructor(private menuListService: MenulistService) {
  }

  ngOnInit() {
    this.menuList = this.menuListService.getMenus();
  }

  // TODO ADD DATA
  addMenu() {
    console.log(this.menuList);
    this.menuListService.addMenu(this.menuName);
    this.menuName = '';
  }
}
//menulist.service.ts
export class MenulistService {
  private menus: string[] = [];

  constructor() { }

  // TODO GET
  getMenus(): string[] {
    return this.menus;
  }

  // TODO ADD
  addMenu(menu: string): void {
    this.menus.push(menu);
  }
}

22. GROCERY LIST COMPONENT AND SERVICES

//grocerylist.component.ts
export class GrocerylistComponent {
  groceryList: string[] = [];
  groceryName: string = '';

  constructor(private groceryListService: GrocerylistService) {
  }

  ngOnInit() {
    this.groceryList = this.groceryListService.getGroceries();
  }

  // TODO ADD DATA
  addGrocery() {
    console.log(this.groceryList);
    this.groceryListService.addGrocery(this.groceryName);
    this.groceryName = '';
  }
}

//grocerylist.service.ts
export class GrocerylistService {
  private groceries: string[] = [];

  constructor() { }

  // TODO GET
  getGroceries(): string[] {
    return this.groceries;
  }

  // TODO ADD
  addGrocery(grocery: string): void {
    this.groceries.push(grocery);
  }
}

23. CLASSROOM LIST COMPONENT AND SERVICES

//classroomlist.component.ts
export class ClassroomlistComponent {
  classroomList: string[] = [];
  classroomName: string = '';

  constructor(private classroomListService: ClassroomlistService) {
  }

  ngOnInit() {
    this.classroomList = this.classroomListService.getClassrooms();
  }

  // TODO ADD DATA
  addClassroom() {
    console.log(this.classroomList);
    this.classroomListService.addClassroom(this.classroomName);
    this.classroomName = '';
  }

}

//classroomlist.service.ts
export class ClassroomlistService {
  private classrooms: string[] = [];

  constructor() { }

  // TODO GET
  getClassrooms(): string[] {
    return this.classrooms;
  }

  // TODO ADD
  addClassroom(classroom: string): void {
    this.classrooms.push(classroom);
  }
}

24. INVENTORY LIST COMPONENT AND SERVICES

//inventorylist.component.ts
export class InventorylistComponent {
  inventoryList: string[] = [];
  inventoryName: string = '';

  constructor(private inventoryListService: InventorylistService) {
  }

  ngOnInit() {
    this.inventoryList = this.inventoryListService.getInventories();
  }

  // TODO ADD DATA
  addInventory() {
    console.log(this.inventoryList);
    this.inventoryListService.addInventory(this.inventoryName);
    this.inventoryName = '';
  }

}

//inventorylist.service.ts
export class InventorylistService {
  private inventories: string[] = [];

  constructor() { }

  // TODO GET
  getInventories(): string[] {
    return this.inventories;
  }

  // TODO ADD
  addInventory(inventory: string): void {
    this.inventories.push(inventory);
  }
}

25. LECTURE LIST COMPONENT AND SERVICES

//lecturelist.component.ts
export class LecturelistComponent {
  lectureList: string[] = [];
  lectureName: string = '';

  constructor(private lectureListService: LecturelistService) {
  }

  ngOnInit() {
    this.lectureList = this.lectureListService.getLectures();
  }

  // TODO ADD DATA
  addLecture() {
    console.log(this.lectureList);
    this.lectureListService.addLecture(this.lectureName);
    this.lectureName = '';
  }
}

//lecturelist.service.ts
export class LecturelistService {
  private lectures: string[] = [];

  constructor() { }

  // TODO GET
  getLectures(): string[] {
    return this.lectures;
  }

  // TODO ADD
  addLecture(lecture: string): void {
    this.lectures.push(lecture);
  }
}

26. STATIONERY LIST COMPONENT AND SERVICES

//stationerylist.component.ts
export class StationerylistComponent {
  stationeryList: string[] = [];
  stationeryName: string = '';

  constructor(private stationeryListService: StationerylistService) {
  }

  ngOnInit() {
    this.stationeryList = this.stationeryListService.getStationeries();
  }

  // TODO ADD DATA
  addStationery() {
    console.log(this.stationeryList);
    this.stationeryListService.addStationery(this.stationeryName);
    this.stationeryName = '';
  }
}

//stationerylist.service.ts
export class StationerylistService {
  private stationeries: string[] = [];

  constructor() { }

  // TODO GET
  getStationeries(): string[] {
    return this.stationeries;
  }

  // TODO ADD
  addStationery(stationery: string): void {
    this.stationeries.push(stationery);
  }
}

27. FLOWER LIST COMPONENT AND SERVICES

//flowerlist.component.ts
export class FlowerlistComponent {
  flowerList: string[] = [];
  flowerName: string = '';

  constructor(private flowerListService: FlowerlistService) {
  }

  ngOnInit() {
    this.flowerList = this.flowerListService.getFlowers();
  }

  // TODO ADD DATA
  addFlower() {
    console.log(this.flowerList);
    this.flowerListService.addFlower(this.flowerName);
    this.flowerName = '';
  }
}

//flowerlist.service.ts
export class FlowerlistService {
  private flowers: string[] = [];

  constructor() { }

  // TODO GET
  getFlowers(): string[] {
    return this.flowers;
  }

  // TODO ADD
  addFlower(flower: string): void {
    this.flowers.push(flower);
  }
}

28. DESTINATION LIST COMPONENT AND SERVICES

//destinationlist.component.ts
export class DestinationlistComponent {
  desinationList: string[] = [];
  destinationName: string = '';

  constructor(private destinationListService: DestionationlistService) {
  }
  ngOnInit() {
    this.desinationList = this.destinationListService.getDestinations();
  }
  // TODO ADD DATA
  addDestination() {
    console.log(this.desinationList);
    this.destinationListService.addDestination(this.destinationName);
    this.destinationName = '';
  }
}
//destionationlist.service.ts
export class DestionationlistService {
  private destinations: string[] = [];

  constructor() { }

  // TODO GET
  getDestinations(): string[] {
    return this.destinations;
  }

  // TODO ADD
  addDestination(destination: string): void {
    this.destinations.push(destination);
  }
}

29. LAPTOP LIST COMPONENT AND SERVICES

//laptoplist.component.ts
export class LaptoplistComponent {
  laptopList: string[] = [];
  laptopName: string = '';

  constructor(private laptopListService: LaptoplistService) {
  }
  ngOnInit() {
    this.laptopList = this.laptopListService.getLaptops();
  }

  // TODO ADD DATA
  addLaptop() {
    console.log(this.laptopList);
    this.laptopListService.addLaptop(this.laptopName);
    this.laptopName = '';
  }
}
//laptoplist.service.ts
export class LaptoplistService {
  private laptops: string[] = [];

  constructor() { }

  // TODO GET
  getLaptops(): string[] {
    return this.laptops;
  }
  // TODO ADD
  addLaptop(laptop: string): void {
    this.laptops.push(laptop);
  }
}

30. LAPTOP SPECIFICATION LIST COMPONENT AND SERVICES

//laptopspecificationlist.component.ts
export class LaptopspecificationlistComponent {
  laptopSpecList: string[] = [];
  laptopSpecName: string = '';

  constructor(private laptopSpecListService: LaptopspecificationlistService) {
  }

  ngOnInit() {
    this.laptopSpecList = this.laptopSpecListService.getLaptopSpecs();
  }

  // TODO ADD DATA
  addLaptopSpec() {
    console.log(this.laptopSpecList);
    this.laptopSpecListService.addLaptopSpec(this.laptopSpecName);
    this.laptopSpecName = '';
  }

}

//laptopspecificationlist.service.ts
export class LaptopspecificationlistService {
  private laptopSpecs: string[] = [];

  constructor() { }

  // TODO GET
  getLaptopSpecs(): string[] {
    return this.laptopSpecs;
  }

  // TODO ADD
  addLaptopSpec(LaptopSpecification: string): void {
    this.laptopSpecs.push(LaptopSpecification);
  }
}

31. COMPUTER HARDWARE LIST COMPONENT AND SERVICES

//computerhardwarelist.component.ts
export class ComputerhardwarelistComponent {
  computerHardwareList: string[] = [];
  computerHardwareName: string = '';

  constructor(private computerHardwareListService: ComputerhardwarelistService) {
  }

  ngOnInit() {
    this.computerHardwareList = this.computerHardwareListService.getComputerHardwares();
  }

  // TODO ADD DATA
  addComputerHardware() {
    console.log(this.addComputerHardware);
    this.computerHardwareListService.addComputerHardware(this.computerHardwareName);
    this.computerHardwareName = '';
  }
}
//computerhardwarelist.service.ts
export class ComputerhardwarelistService {
  private computerHardwares: string[] = [];

  constructor() { }

  // TODO GET
  getComputerHardwares(): string[] {
    return this.computerHardwares;
  }

  // TODO ADD
  addComputerHardware(computerHardware: string): void {
    this.computerHardwares.push(computerHardware);
  }
}
  1. MOBILE APP LIST COMPONENT AND SERVICES
//mobileapplist.component.ts
export class MobileapplistComponent {
  mobileAppList: string[] = [];
  mobileAppName: string = '';

  constructor(private mobileAppListService: MobileapplistService) {
  }

  ngOnInit() {
    this.mobileAppList = this.mobileAppListService.getMobileApps();
  }

  // TODO ADD DATA
  addMobileApp() {
    console.log(this.mobileAppList);
    this.mobileAppListService.addMobileApp(this.mobileAppName);
    this.mobileAppName = '';
  }
}
//mobileapplist.service.ts
export class MobileapplistService {
  private mobileApps: string[] = [];

  constructor() { }

  // TODO GET
  getMobileApps(): string[] {
    return this.mobileApps;
  }

  // TODO ADD
  addMobileApp(mobileApp: string): void {
    this.mobileApps.push(mobileApp);
  }
}

33. VIDEO LIST COMPONENT AND SERVICES

//videolist.component.ts
export class VideolistComponent {
  videoList: string[] = [];
  videoName: string = '';

  constructor(private videoListService: VideolistService) {
  }

  ngOnInit() {
    this.videoList = this.videoListService.getVideos();
  }

  // TODO ADD DATA
  addVideo() {
    console.log(this.videoList);
    this.videoListService.addVideo(this.videoName);
    this.videoName = '';
  }
}

//videolist.service.ts
export class VideolistComponent {
  videoList: string[] = [];
  videoName: string = '';

  constructor(private videoListService: VideolistService) {
  }

  ngOnInit() {
    this.videoList = this.videoListService.getVideos();
  }

  // TODO ADD DATA
  addVideo() {
    console.log(this.videoList);
    this.videoListService.addVideo(this.videoName);
    this.videoName = '';
  }
}

34. TV SHOW LIST COMPONENT AND SERVICES

//tvshowlist.component.ts
export class TvshowlistComponent {
  tvShowList: string[] = [];
  tvShowName: string = '';

  constructor(private tvShowListService: TvshowlistService) {
  }

  ngOnInit() {
    this.tvShowList = this.tvShowListService.getTvShows();
  }

  // TODO ADD DATA
  addTvShow() {
    console.log(this.tvShowList);
    this.tvShowListService.addTvShow(this.tvShowName);
    this.tvShowName = '';
  }
}
//tvshowlist.service.ts
export class TvshowlistService {
  private tvShows: string[] = [];

  constructor() { }

  // TODO GET
  getTvShows(): string[] {
    return this.tvShows;
  }

  // TODO ADD
  addTvShow(tvShow: string): void {
    this.tvShows.push(tvShow);
  }
}
  1. FURNITURE LIST COMPONENT AND SERVICES
//furniturelist.component.ts
export class FurniturelistComponent {
  furnitureList: string[] = [];
  furnitureName: string = '';

  constructor(private furnitureListService: FurniturelistService) {
  }

  ngOnInit() {
    this.furnitureList = this.furnitureListService.getFurnitures();
  }

  // TODO ADD DATA
  addFurniture() {
    console.log(this.furnitureList);
    this.furnitureListService.addFurnitures(this.furnitureName);
    this.furnitureName = '';
  }
}
//furniturelist.service.ts
export class FurniturelistService {
  private furnitures: string[] = [];

  constructor() { }

  // TODO GET
  getFurnitures(): string[] {
    return this.furnitures;
  }

  // TODO ADD
  addFurnitures(furniture: string): void {
    this.furnitures.push(furniture);
  }
}

36. ACCESSORIES LIST COMPONENT AND SERVICES

//accessorieslist.component.ts
export class AccessorylistComponent {
  accesoryList: string[] = [];
  accesoryName: string = '';

  constructor(private accessoryListService: AccessorieslistService) {
  }

  ngOnInit() {
    this.accesoryList = this.accessoryListService.getAccessories();
  }

  // TODO ADD DATA
  addAccessory() {
    console.log(this.accesoryList);
    this.accessoryListService.addAccessories(this.accesoryName);
    this.accesoryName = '';
  }
}
//accessorieslist.service.ts
export class AccessorieslistService {
  private accessories: string[] = [];

  constructor() { }

  // TODO GET
  getAccessories(): string[] {
    return this.accessories;
  }

  // TODO ADD
  addAccessories(accessory: string): void {
    this.accessories.push(accessory);
  }
}

37. BUILDING LIST COMPONENT AND SERVICES

//buildinglist.component.ts
export class BuildinglistComponent {
  buildingList: string[] = [];
  buildingName: string = '';

  constructor(private buildingListService: BuildinglistService) {
  }

  ngOnInit() {
    this.buildingList = this.buildingListService.getBuildings();
  }

  // TODO ADD DATA
  addBuilding() {
    console.log(this.buildingList);
    this.buildingListService.addBuilding(this.buildingName);
    this.buildingName = '';
  }
}

//buildinglist.service.ts
export class BuildinglistService {
  private buildings: string[] = [];

  constructor() { }

  // TODO GET
  getBuildings(): string[] {
    return this.buildings;
  }

  // TODO ADD
  addBuilding(building: string): void {
    this.buildings.push(building);
  }
}

38. PAINTING LIST COMPONENT AND SERVICES

//paintinglist.component.ts
export class PaintinglistComponent {
  paintingList: string[] = [];
  paintingName: string = '';

  constructor(private paintingListService: PaintinglistService) {
  }

  ngOnInit() {
    this.paintingList = this.paintingListService.getPaintings();
  }

  // TODO ADD DATA
  addPainting() {
    console.log(this.paintingList);
    this.paintingListService.addPainting(this.paintingName);
    this.paintingName = '';
  }
}
//paintinglist.service.ts
export class PaintinglistService {
  private paintings: string[] = [];

  constructor() { }

  // TODO GET
  getPaintings(): string[] {
    return this.paintings;
  }

  // TODO ADD
  addPainting(painting: string): void {
    this.paintings.push(painting);
  }
}

39. ARTISTS LIST COMPONENT AND SERVICES

//artistlist.component.ts
  artistList: string[] = [];
  artistName: string = '';

  constructor(private artistListService: ArtistlistService) {
  }

  ngOnInit() {
    this.artistList = this.artistListService.getArtists();
  }

  // TODO ADD DATA
  addArtist() {
    console.log(this.artistList);
    this.artistListService.addArtist(this.artistName);
    this.artistName = '';
  }
}
//artistlist.service.ts
export class ArtistlistService {
  private artists: string[] = [];

  constructor() { }

  // TODO GET
  getArtists(): string[] {
    return this.artists;
  }

  // TODO ADD
  addArtist(artist: string): void {
    this.artists.push(artist);
  }
}

40. COMPOSER LIST COMPONENT AND SERVICES

//composerlist.component.ts
export class ComposerlistComponent {
  composerList: string[] = [];
  composerName: string = '';

  constructor(private composerListService: ComposerlistService) {
  }

  ngOnInit() {
    this.composerList = this.composerListService.getComposers();
  }

  // TODO ADD DATA
  addComposer() {
    console.log(this.composerList);
    this.composerListService.addComposer(this.composerName);
    this.composerName = '';
  }
}
//composerlist.service.ts
export class ComposerlistService {
  private composers: string[] = [];

  constructor() { }

  // TODO GET
  getComposers(): string[] {
    return this.composers;
  }

  // TODO ADD
  addComposer(composer: string): void {
    this.composers.push(composer);
  }
}

41. PODCAST LIST COMPONENT AND SERVICES

//podcastlist.component.ts
export class PodcastlistComponent {
  podcastList: string[] = [];
  podcastName: string = '';

  constructor(private podcastListService: PodcastlistService) {
  }

  ngOnInit() {
    this.podcastList = this.podcastListService.getPodcasts();
  }

  // TODO ADD DATA
  addPodcast() {
    console.log(this.podcastList);
    this.podcastListService.addPodcast(this.podcastName);
    this.podcastName = '';
  }
}
//podcastlist.service.ts
export class PodcastlistService {
  private podcasts: string[] = [];

  constructor() { }

  // TODO GET
  getPodcasts(): string[] {
    return this.podcasts;
  }

  // TODO ADD
  addPodcast(podcast: string): void {
    this.podcasts.push(podcast);
  }
}

42. EXERCISE LIST COMPONENT AND SERVICES

//exerciselist.component.ts
export class ExerciselistComponent {
  exerciseList: string[] = [];
  exerciseName: string = '';

  constructor(private exerciseListService: ExerciselistService) {
  }

  ngOnInit() {
    this.exerciseList = this.exerciseListService.getExercises();
  }

  // TODO ADD DATA
  addExercise() {
    console.log(this.exerciseList);
    this.exerciseListService.addExercise(this.exerciseName);
    this.exerciseName = '';
  }
}
//exerciselist.service.ts
export class ExerciselistService {
  private exercises: string[] = [];

  constructor() { }

  // TODO GET
  getExercises(): string[] {
    return this.exercises;
  }

  // TODO ADD
  addExercise(exercise: string): void {
    this.exercises.push(exercise);
  }
}

43. MEAL PLAN LIST COMPONENT AND SERVICES

//mealplanlist.component.ts
export class MealplanlistComponent {
  mealPlanList: string[] = [];
  mealPlanName: string = '';

  constructor(private mealPlanListService: MealplanlistService) {
  }

  ngOnInit() {
    this.mealPlanList = this.mealPlanListService.getMealPlans();
  }

  // TODO ADD DATA
  addMealPlan() {
    console.log(this.mealPlanList);
    this.mealPlanListService.addMealPlan(this.mealPlanName);
    this.mealPlanName = '';
  }
}
//mealplantlist.service.ts
export class MealplanlistService {
  private mealPlans: string[] = [];

  constructor() { }

  // TODO GET
  getMealPlans(): string[] {
    return this.mealPlans;
  }

  // TODO ADD
  addMealPlan(mealPlan: string): void {
    this.mealPlans.push(mealPlan);
  }
}

44. BUDGET LIST COMPONENT AND SERVICES

//budgetlist.component.ts
export class BudgetlistComponent {
  budgetList: string[] = [];
  budgetName: string = '';

  constructor(private budgetListService: BudgetlistService) {
  }

  ngOnInit() {
    this.budgetList = this.budgetListService.getBudgets();
  }

  // TODO ADD DATA
  addBudget() {
    console.log(this.budgetList);
    this.budgetListService.addBudget(this.budgetName);
    this.budgetName = '';
  }
}
//budgetlist.service.ts
export class BudgetlistService {
  private budgets: string[] = [];

  constructor() { }

  // TODO GET
  getBudgets(): string[] {
    return this.budgets;
  }

  // TODO ADD
  addBudget(budget: string): void {
    this.budgets.push(budget);
  }
}

45. PRESENTATION LIST COMPONENT AND SERVICES

//presentationlist.component.ts
export class PresentationlistComponent {
  presentationList: string[] = [];
  presentationName: string = '';

  constructor(private presentationListService: PresentationlistService) {
  }

  ngOnInit() {
    this.presentationList = this.presentationListService.getPresentations();
  }

  // TODO ADD DATA
  addPresentation() {
    console.log(this.presentationList);
    this.presentationListService.addPresentation(this.presentationName);
    this.presentationName = '';
  }
}
//presentationlist.service.ts
export class PresentationlistService {
  private presentations: string[] = [];

  constructor() { }

  // TODO GET
  getPresentations(): string[] {
    return this.presentations;
  }

  // TODO ADD
  addPresentation(presentation: string): void {
    this.presentations.push(presentation);
  }
}

46. TOUR LIST COMPONENT AND SERVICES

//tourlist.component.ts

//tourlist.service.ts

47. EVENT LIST COMPONENT AND SERVICES

//eventlist.component.ts
export class EventlistComponent {
  eventList: string[] = [];
  eventName: string = '';

  constructor(private eventListService: EventlistService) {
  }

  ngOnInit() {
    this.eventList = this.eventListService.getEvents();
  }

  // TODO ADD DATA
  addEvent() {
    console.log(this.eventList);
    this.eventListService.addEvent(this.eventName);
    this.eventName = '';
  }
}

//eventlist.service.ts
export class EventlistService {

  private events: string[] = [];

  constructor() { }

  // TODO GET
  getEvents(): string[] {
    return this.events;
  }

  // TODO ADD
  addEvent(event: string): void {
    this.events.push(event);
  }
}

48. DEVELOPER TOOL LIST COMPONENT AND SERVICES

//developertoollist.component.ts
export class DevelopertoollistComponent {
  devToolList: string[] = [];
  devToolName: string = '';

  constructor(private studentListService: DevelopertoollistService) {
  }

  ngOnInit() {
    this.devToolList = this.studentListService.getDeveloperTools();
  }

  // TODO ADD DATA
  addDeveloperTool() {
    console.log(this.devToolList);
    this.studentListService.addDeveloperTools(this.devToolName);
    this.devToolName = '';
  }
}

//developertoollist.service.ts
export class DevelopertoollistService {
  private developerTools: string[] = [];

  constructor() { }

  // TODO GET
  getDeveloperTools(): string[] {
    return this.developerTools;
  }

  // TODO ADD
  addDeveloperTools(devTool: string): void {
    this.developerTools.push(devTool);
  }
}

49. FRAMEWORK LIST COMPONENT AND SERVICES

//frameworklist.component.ts
export class FrameworklistComponent {
  frameworkList: string[] = [];
  frameworkName: string = '';

  constructor(private frameworkListService: FrameworklistService) {
  }

  ngOnInit() {
    this.frameworkList = this.frameworkListService.getFrameworks();
  }

  // TODO ADD DATA
  addFramework() {
    console.log(this.frameworkList);
    this.frameworkListService.addFramework(this.frameworkName);
    this.frameworkName = '';
  }
}
//frameworklist.service.ts
export class FrameworklistService {
  private frameworks: string[] = [];

  constructor() { }

  // TODO GET
  getFrameworks(): string[] {
    return this.frameworks;
  }
  // TODO ADD
  addFramework(framework: string): void {
    this.frameworks.push(framework);
  }
}

50. LIBRARY LIST COMPONENT AND SERVICES

//librarylist.component.ts
export class LibrarylistComponent {
  libraryList: string[] = [];
  libraryName: string = '';

  constructor(private libraryListService: LibrarylistService) {
  }

  ngOnInit() {
    this.libraryList = this.libraryListService.getLibraries();
  }

  // TODO ADD DATA
  addLibrary() {
    console.log(this.libraryList);
    this.libraryListService.addLibrary(this.libraryName);
    this.libraryName = '';
  }
}

//librarylist.service.ts
export class LibrarylistService {
  private libraries: string[] = [];

  constructor() { }

  // TODO GET
  getLibraries(): string[] {
    return this.libraries;
  }

  // TODO ADD
  addLibrary(library: string): void {
    this.libraries.push(library);
  }
}

Firebase hosting link: https://rodny-angularservice.web.app/

Repository Link: https://github.com/rodney-lqr/AngularServices

More from this blog