Skip to content

Patch 2 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 5, 2019
6 changes: 5 additions & 1 deletion docs/content/guide/di.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and providing them to other components as requested.

## Using Dependency Injection

Dependency Injection is pervasive throughout AngularJS. You can use it when defining components
Dependency Injection is pervasive throughout AngularJS.
You can use it when defining components
or when providing `run` and `config` blocks for a module.

- {@link angular.Module#service Services}, {@link angular.Module#directive directives},
Expand Down Expand Up @@ -283,9 +284,12 @@ Here is an example of using the injector service:
// Provide the wiring information in a module
var myModule = angular.module('myModule', []);
```
Notice that `myModule` depends upon no other modules as the second parameter is an empty array.
Dependent is always need dependency object to be injected inside it.

Teach the injector how to build a `greeter` service. Notice that `greeter` is dependent on the
`$window` service. The `greeter` service is an object that contains a `greet` method.
so, injector now injects `$window` dependency inside `greeter` service.

```js
myModule.factory('greeter', function($window) {
Expand Down