💉 Dependency Injection

Use dependency injection (DI) to create services

Generate a Service

command line
ng g service clock

Use-Cases for Services

Services can inject shared data and methods into your components. They are also useful for writing code that maintains a DRY separation of concerns.

  • Shared state. Services can connect data between components and are especially useful when components are not in a child/parent relationship.
  • Shared logic. Stateless services that define common methods used in multiple components.

Questions? Let's chat

Open Discord