Modern Angular Design PatternsBuy the book
PreviousNext
The comic: Nine Carts

Chapter 4: Reusable Services

Centralizing business logic and sharing behavior across the application with services.

  • Dependency injection
  • Injection tokens
  • Iterator
  • Service layer

What you can try in this demo

Seven demos move business logic out of components: a service layer, services that inject other services, and API data fetched through dependency injection. Injection tokens, the Singleton pattern as Angular provides it, and the Iterator pattern walking a tree, plain and with RxJS, each run in their own card.

This demo is chapter 4 of Modern Angular Design Patterns. The book walks through the code behind it.

Buy the book