Dependency injections or DI is used by the framework to instantiate view models such as custom components, attributes or elements created as classes through the DI container. These classes are designed to be small and attain a common task. This way, the code is modularized and easy to test.
To use this in code, you must import inject library to make use of the inject() decorator.
For this instance, we used ES2016 and added the HttpClient inside the inject() decorator and added the http parameter to its constructor. What it does here is that the inject() decorator should pass a list of type to provide instances of. Then for each constructor parameters, there should be one argument such as http.
For ES2015, this is added by writing a static inject method to a class that returns an array of types to inject whereas TypeScript 1.5 or lower is added by writing @autoinject decorator to a class and choose the Types in the decorator call. But it’s just used on constructor’s signature.