Dependency Injection is a common design pattern to deal with dependencies. Instead of creating instances of dependencies yourself when you need them, you leave this task to a dependency injection mechanism. This mechanism instantiates the dependencies when needed and gives you access to these instances, in order to avoid having to create and deal with too many instances of the same thing.
Angular, as the complete JavaScript framework it is, comes with its own dependency injection mechanism. Most of the time, the dependencies we are talking about are services. To learn more about how to inject services you can check this article. But dependency injection is not limited to services. You can use it to inject (almost) anything you like, for example objects. However, while a syntax shortcut makes injecting a service pretty straight-forward, there is a bit more work when injecting other types of objects.

#dependency-injection #javascript #web-development #angular

Inject Objects Into Your Component with Angular Dependency Injection
4.15 GEEK