Why do two Angular components receive different instances of one service?

Angular fundamentalsFoundations & codingAbout 9 minutes

Understand the idea, explain it in your own words and use the rubric to find your next learning gap.

Local drafts · no account or AI calls
Sukoaa original

The idea behind the question

Angular dependency injection resolves a token through an injector hierarchy. Providing a service at a component boundary can create an instance with a narrower lifetime than a root-provided service.

AN ILLUSTRATIVE EXAMPLE

Two independent editors provide the same draft service locally so their current drafts do not overwrite each other.

A practical way to learn it

Create two independent counter panels with component-scoped services, then move the provider to a shared scope and describe how the behavior changes.

Open Angular project studio

The related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.

Build an explanation you understand

  1. State what the concept does in plain language.
  2. Apply it to the example and make your assumptions explicit.
  3. Explain a trade-off, failure case and how you would test it.
  4. Distinguish your actual experience from a proposed approach.

Further reading

Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.