Another key building block of Angular services. Following Angular's architecture, services are supposed to encapsulate business logic and application-wide states. Additionally, services are useful to bridge between different components that aren't necessarily a direct parent and child.
As this is your first services-related task, extract the categories data to an Angular service.
First, generate the CategoriesService service, as part of the CoreModule, by executing the following command:
ng generate service modules/core/services/categories
Afterward, the service is created in a file named categories.service.ts, containing the following content:
import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' ...