Services are used to implement common functionality across modules.
For eg:-it is most commonly used for database activity through http client package
and also you can use for logging errors in the application.
Enter this command in Angular command line interface ,
ng g service mycustomservice
This will create 2 files,
export class app{
constructor(private objcustomservice: mycustomservice) {}
FetchRecords():void
{
objcustomservice.somemethod();
}