Providers and Scopes
Control where services live in the tree.
Providers and Scopes
A provider tells Angular how to create a dependency. The scope where you register it determines how many instances exist and who shares them.
Root Scope
providedIn: root registers a service in the root injector: one shared singleton for the entire app. This is the most common choice.
@Injectable({ providedIn: 'root' })
export class AppStore {}All lessons in this course
- Services and Injectable
- The inject Function
- Providers and Scopes
- Injection Tokens