
Learning Angular
By :

To create a new Angular service, we use the ng generate
command of the Angular CLI while passing the name of the service as a parameter:
ng generate service products
Running the preceding command will create the products
service that consists of the products.service.ts
file and its accompanying unit test file, products.service.spec.ts
.
We usually name a service after the functionality that it represents. Every service has a business context or domain that operates. When it starts to cross boundaries between different contexts, this is an indication that you should break it into different services. A products service should be concerned with products. Similarly, orders should be managed by a separate orders service.
An Angular service is a TypeScript class marked with the @Injectable
decorator. The decorator identifies the class as an Angular service that can be injected into other Angular artifacts such as components, directives, or even other services...