Another fundamental aspect of Angular is a service. These can be thought of as a class that is responsible for some processing or data fetching logic. A component uses a service class to delegate the responsibility of fetching data over HTTP or other processing, which keeps the component code clean. Components can be injected with the services they need using dependency injection. The injection is done using the components constructor which references the service class. Angular obtains the service from an injector, which maintains the already created service instances and returns a new one if it doesn't exist. Here's the constructor of DashboardComponent class, which can be rewritten to use DashboardService:
constructor(private service: DashboardService) { }
//Use lifecyle-hook ngOnInit to perform complex fetch operation
ngOnInit(): void {
this.stats = this...