@@ -105,17 +105,17 @@ dependencies of `MyController` without the controller ever knowing about the inj
105
105
the best outcome. The application code simply asks for the dependencies it needs, without having to
106
106
deal with the injector. This setup does not break the Law of Demeter.
107
107
108
- # Dependency Annotation
108
+ ## Dependency Annotation
109
109
110
110
How does the injector know what service needs to be injected?
111
111
112
112
The application developer needs to provide annotation information that the injector uses in order
113
- to resolve the dependencies. Throughout Angular certain API functions are invoked using the
113
+ to resolve the dependencies. Throughout Angular, certain API functions are invoked using the
114
114
injector, as per the API documentation. The injector needs to know what services to inject into
115
115
the function. Below are three equivalent ways of annotating your code with service name
116
116
information. These can be used interchangeably as you see fit and are equivalent.
117
117
118
- # Inferring Dependencies
118
+ ### Inferring Dependencies
119
119
120
120
The simplest way to get hold of the dependencies, is to assume that the function parameter names
121
121
are the names of the dependencies.
@@ -134,7 +134,7 @@ While straightforward, this method will not work with JavaScript minifiers/obfus
134
134
rename the method parameter names. This makes this way of annotating only useful for {@link
135
135
http://www.pretotyping.org/ pretotyping}, and demo applications.
136
136
137
- # `$inject` Annotation
137
+ ### `$inject` Annotation
138
138
139
139
To allow the minifers to rename the function parameters and still be able to inject right services
140
140
the function needs to be annotated with the `$inject` property. The `$inject` property is an array
@@ -153,7 +153,7 @@ function declaration.
153
153
This method of annotation is useful for controller declarations since it assigns the annotation
154
154
information with the function.
155
155
156
- # Inline Annotation
156
+ ### Inline Annotation
157
157
158
158
Sometimes using the `$inject` annotation style is not convenient such as when annotating
159
159
directives.
@@ -189,11 +189,11 @@ For this reason the third annotation style is provided as well.
189
189
Keep in mind that all of the annotation styles are equivalent and can be used anywhere in Angular
190
190
where injection is supported.
191
191
192
- # Where can I use DI?
192
+ ## Where can I use DI?
193
193
194
194
DI is pervasive throughout Angular. It is typically used in controllers and factory methods.
195
195
196
- ## DI in controllers
196
+ ### DI in controllers
197
197
198
198
Controllers are classes which are responsible for application behavior. The recommended way of
199
199
declaring controllers is:
@@ -209,7 +209,7 @@ declaring controllers is:
209
209
</pre>
210
210
211
211
212
- ## Factory methods
212
+ ### Factory methods
213
213
214
214
Factory methods are responsible for creating most objects in Angular. Examples are directives,
215
215
services, and filters. The factory methods are registered with the module, and the recommended way
0 commit comments