Skip to content

Commit

Permalink
docs(guide/di): fix headings hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
Ore4444 authored and petebacondarwin committed Jun 13, 2013
1 parent 45ee884 commit cd3dd13
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/content/guide/di.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ dependencies of `MyController` without the controller ever knowing about the inj
the best outcome. The application code simply asks for the dependencies it needs, without having to
deal with the injector. This setup does not break the Law of Demeter.

# Dependency Annotation
## Dependency Annotation

How does the injector know what service needs to be injected?

The application developer needs to provide annotation information that the injector uses in order
to resolve the dependencies. Throughout Angular certain API functions are invoked using the
to resolve the dependencies. Throughout Angular, certain API functions are invoked using the
injector, as per the API documentation. The injector needs to know what services to inject into
the function. Below are three equivalent ways of annotating your code with service name
information. These can be used interchangeably as you see fit and are equivalent.

# Inferring Dependencies
### Inferring Dependencies

The simplest way to get hold of the dependencies, is to assume that the function parameter names
are the names of the dependencies.
Expand All @@ -134,7 +134,7 @@ While straightforward, this method will not work with JavaScript minifiers/obfus
rename the method parameter names. This makes this way of annotating only useful for {@link
http://www.pretotyping.org/ pretotyping}, and demo applications.

# `$inject` Annotation
### `$inject` Annotation

To allow the minifers to rename the function parameters and still be able to inject right services
the function needs to be annotated with the `$inject` property. The `$inject` property is an array
Expand All @@ -153,7 +153,7 @@ function declaration.
This method of annotation is useful for controller declarations since it assigns the annotation
information with the function.

# Inline Annotation
### Inline Annotation

Sometimes using the `$inject` annotation style is not convenient such as when annotating
directives.
Expand Down Expand Up @@ -189,11 +189,11 @@ For this reason the third annotation style is provided as well.
Keep in mind that all of the annotation styles are equivalent and can be used anywhere in Angular
where injection is supported.

# Where can I use DI?
## Where can I use DI?

DI is pervasive throughout Angular. It is typically used in controllers and factory methods.

## DI in controllers
### DI in controllers

Controllers are classes which are responsible for application behavior. The recommended way of
declaring controllers is:
Expand All @@ -209,7 +209,7 @@ declaring controllers is:
</pre>


## Factory methods
### Factory methods

Factory methods are responsible for creating most objects in Angular. Examples are directives,
services, and filters. The factory methods are registered with the module, and the recommended way
Expand Down

0 comments on commit cd3dd13

Please sign in to comment.