0 votes
in Angular by
What is Dependency Injection and How Does It Work in Angular?

1 Answer

0 votes
by

Dependency injection is a process where we inject the dependent objects rather than consumer creating the objects. DI is everywhere in Angular or we can go one step ahead and say Angular cannot work without DI.

For example in the below code, $scope and $http objects are created and injected by the Angular framework. The consumer, i.e., CustomerController does not create these objects himself rather Angular injects these objects.

JavaScript
function CustomerController($scope,$http)
{
// your consumer would be using the scope and http objects
}

Related questions

0 votes
asked Dec 31, 2023 in Angular by DavidAnderson
0 votes
asked Dec 29, 2023 in Angular by DavidAnderson
...