A component’s job is to render data. Thus, making sure that it has data, and renders the data the right way, and sometimes makes sure that it dispatches the right data to its children.
If we delegate fetching and managing data to the component, this would be too much to manage. Besides that, if we have a problem rendering the component, tests will be much more time consuming since we do data fetching and management, and rendering in the same component. Any changes in the future would be harder to implement and test. That’s why this type of design is a terrible practice.
Angular is built in a way that you won’t have this issue by using services and dependency injection so that:
In this article, I’ll be covering:
#angular #dependency-injection #typescript #web-development