latest Post

Explain what is Dependency Injection in AngularJS?

Dependency Injection is one of the best features of AngularJS. It is a software design pattern in which objects are passed as dependencies. It helps us to remove hard coded dependencies and makes dependencies configurable. Using Dependency Injection, we can make components maintainable, reusable and testable.

Dependency Injection is required for the following

    Separating the process of creation and consumption of dependencies.
    It allows us to create independent development of the dependencies.
    We can change the dependencies when required.
    It allows injecting mock objects as dependencies for testing.

AngularJS uses dependency with several types

    Value
    Factory
    Service
    Provider
    Constant

A simple case of dependency injection in Angular js

    AppModule.controller("AppController", function($scope, $window, $log,$http)
    {
   
    });

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment