Restricting DI Down the Component Tree
Learn how to restrict dependency access and lookup in Angular components by using decorators.
We'll cover the following
We saw how ProductListComponent
registered ProductsService
, making it immediately available to all the child components. A component may contain child components at different levels. That is, its child components can have other child components, and so on. Sometimes, we might need to restrict dependency access to components located next to a specific component in the hierarchy. We can do that by registering the service in the viewProviders
property of the @Component
decorator:
Get hands-on with 1200+ tech skills courses.