Injecting services in the component tree
The @Component
decorator has a providers
property to register services with an element injector. A service that registers with the element injector can serve two purposes:
- It can be shared with its child components
- It can create multiple copies of the service every time the component that provides the service is rendered
In the following sections, we’ll learn how to apply each approach.