Angular Services and the Singleton Pattern
One of the great differences between a static web page and a single-page application is the processing capacity and interaction in the user’s browser, giving the feeling of an application installed on the device. In the Angular framework, the elements for this processing and interaction, not only with the backend but with the user, are the services.
This element is so important to Angular that the team created a dependency management system, which allows a simplified way of creating, composing, and using services in components.
In this chapter, we will explore this element and learn about the design patterns it uses and the best practices to use in your project.
Here we will cover the following topics:
- Creating services
- Understanding the dependency injection pattern
- Communication between components using services
- REST API consumption
By the end of the chapter, you will be able to create reusable and...