Search⌘ K

Creating Services for Client Contacts Manager Application

Explore how to create and use Angular services to manage client and company data in a sales contacts application. Understand dependency injection, mock REST APIs with in-memory-web-api, and integrate forms for adding, editing, and deleting records.

Major changes

In this version of the application, we have made the following changes:

  • Added Services, one for the Client section and one for the Company section.

  • Added forms for Adding, Editing, and Deleting both Clients and Companies.

  • Used angular-in-memory-web-api to store data locally.

  • Added lazy loading of routes.

app/services

This contains a service, in-memory-data.service.ts, which uses a third-party library to provide make mock REST API calls to local memory. This allows the user to build a REST API to write data without having to use a hosting service. This service will be used by both the Client and Company Services.

import { Injectable } from '@angular/core';
import { InMemoryDbService } from 'angular-in-memory-web-api';
import { Client } from '../clients/client';

@Injectable({
  providedIn: 'root'
})
export class InMemoryDataService implements InMemoryDbService {
 
...