|
10 | 10 | * Creates an injector object that can be used for retrieving services as well as for |
11 | 11 | * dependency injection (see {@link guide/di dependency injection}). |
12 | 12 | * |
13 | | -
|
14 | 13 | * @param {Array.<string|Function>} modules A list of module functions or their aliases. See |
15 | | - * {@link angular.module}. The `ng` module must be explicitly added. |
| 14 | + * {@link angular.module}. The `ng` module must be explicitly added. |
| 15 | + * @param {boolean=} [strictDi=false] Whether the injector should be in strict mode, which |
| 16 | + * disallows argument name annotation inference. |
16 | 17 | * @returns {injector} Injector object. See {@link auto.$injector $injector}. |
17 | 18 | * |
18 | 19 | * @example |
@@ -158,8 +159,10 @@ function annotate(fn, strictDi, name) { |
158 | 159 | * ## Inference |
159 | 160 | * |
160 | 161 | * In JavaScript calling `toString()` on a function returns the function definition. The definition |
161 | | - * can then be parsed and the function arguments can be extracted. *NOTE:* This does not work with |
162 | | - * minification, and obfuscation tools since these tools change the argument names. |
| 162 | + * can then be parsed and the function arguments can be extracted. This method of discovering |
| 163 | + * annotations is disallowed when the injector is in strict mode. |
| 164 | + * *NOTE:* This does not work with minification, and obfuscation tools since these tools change the |
| 165 | + * argument names. |
163 | 166 | * |
164 | 167 | * ## `$inject` Annotation |
165 | 168 | * By adding an `$inject` property onto a function the injection parameters can be specified. |
@@ -244,6 +247,8 @@ function annotate(fn, strictDi, name) { |
244 | 247 | * expect(injector.annotate(MyController)).toEqual(['$scope', '$route']); |
245 | 248 | * ``` |
246 | 249 | * |
| 250 | + * You can disallow this method by using strict injection mode. |
| 251 | + * |
247 | 252 | * This method does not work with code minification / obfuscation. For this reason the following |
248 | 253 | * annotation strategies are supported. |
249 | 254 | * |
@@ -296,6 +301,8 @@ function annotate(fn, strictDi, name) { |
296 | 301 | * @param {Function|Array.<string|Function>} fn Function for which dependent service names need to |
297 | 302 | * be retrieved as described above. |
298 | 303 | * |
| 304 | + * @param {boolean=} [strictDi=false] Disallow argument name annotation inference. |
| 305 | + * |
299 | 306 | * @returns {Array.<string>} The names of the services which the function requires. |
300 | 307 | */ |
301 | 308 |
|
|
0 commit comments