Dependency Injection (DI):- It is a software design pattern and its main motive is to see how components get its dependencies
Injector subsystem in AngularJS is liable for creating components, dependencies resolving and also providing other components as requested.
Using Dependency Injection
DI is common throughout AngularJS. You can use it when defining a component or when providing a module run and config blocks.
Components such as services, directives, filters, and animations are defined by an injectable factory method or constructor function. These components can be injected with "service" and "value" components as dependencies.
Controllers are defined by a constructor function, which can be injected with any of the "service" and "value" components as dependencies, but they can also be provided with special dependencies.
The run method accepts a function, which can be injected with "service", "value" and "constant" components as dependencies. Note that you cannot inject "providers" into run blocks.
The config method accepts a function, which can be injected with "provider" and "constant" components as dependencies. Note that you cannot inject "service" or "value" components into configuration.
0 Comment(s)