Services
A service is a class with @Injectable that holds shared work: fetch marks, cache them, compute totals. Components stay thin. Two pages inject the same MarksService and see the same data if providedIn: 'root'.
Board: MarksPage and ReportPage both call marksService.list(). Don’t new MarksService() inside a component — you get two copies and a bug that looks like ‘state reset’.
Trap: putting HTTP + alert() + routing inside one service method. Split: data in the service, navigation in the component.
MarksPage ──inject──► MarksService ReportPage ──inject──► MarksService one root instance
Exam tip
Why DI, not new. One MarksService example.