EnriqueMark
Angular

Services

2026-04 English

The way you use Angular’s Service looks a lot like a Hook. The biggest difference between them is that a Hook in React can only share state inside a component, while Angular’s Service is shared globally.

Their design logic is still about the same:

  1. Throw the reusable logic that has nothing to do with UI rendering (or just all of the logic) into the Service.
  2. As long as it isn’t about UI rendering. The component of course only holds the UI.

Then the other difference is that you have to inject it before use, you can only use it after it’s injected.

One more note on inject here. angular’s old syntax handed in all the outside functions you wanted through the constructor, but now a plain inject covers everything.

// old style
constructor(private fb: FormBuilder) {}
// new style
private fb = inject(FormBuilder);

Translation note. I wrote this in Chinese. This English version is an LLM translation, so the wording is not mine even though the thinking is. Original: 服務.