Key aspects of Angular data services
In Chapter 6, Getting Started with Angular, you learned that Angular recommends components to delegate tasks related to server communication to one or more services. These services can also be called data services. Some of the key aspects of creating data services which can invoke server APIs such as Spring RESTful APIs are:
- Dependency injection: Inject the HTTP service as appropriate in the constructor of the service class
- HTTP APIs invocation: Invoke the appropriate APIs on the HTTP or the
HttpClient
service which sends requests to the server APIs for performing CRUD (create, retrieve, update, delete) operations on business entities - Response processing: Process server responses in the form of parsing the JSON data and converting it to JavaScript objects, or handle the exception as appropriate
- Returns response: Return Observable to the caller component or service
Before and looking into examples related to building Angular services for RESTful integration...