Services and DI fundamentals
Learn Services and DI fundamentals (Module 8 · Services and Dependency Injection, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is a service? Service architecture • A service is an ordinary TypeScript class that holds logic or data that more than one component needs: calling APIs, storing the logged-in user, calculating prices. Think of it as a shared kitchen: components are dining tables; they should not each cook the food. • Service architecture : keep components thin (display and user events) and put business logic and data access in services. It is exactly the Spring layering of controller, service and repository, applied to the browser. • Generate with ng generate service courses/course (short ng g s ), which...