Skip to content

Commit 920b595

Browse files
committed
doc(injector): adds strictDi documentation to appropriate methods.
Closes angular#9624
1 parent 3109342 commit 920b595

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Angular.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ function angularInit(element, bootstrap) {
13321332
* following keys are supported:
13331333
*
13341334
* - `strictDi`: disable automatic function annotation for the application. This is meant to
1335-
* assist in finding bugs which break minified code.
1335+
* assist in finding bugs which break minified code. Defaults to false.
13361336
*
13371337
* @returns {auto.$injector} Returns the newly created injector for this app.
13381338
*/

src/auto/injector.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
* Creates an injector object that can be used for retrieving services as well as for
1111
* dependency injection (see {@link guide/di dependency injection}).
1212
*
13-
1413
* @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.
1617
* @returns {injector} Injector object. See {@link auto.$injector $injector}.
1718
*
1819
* @example
@@ -158,8 +159,10 @@ function annotate(fn, strictDi, name) {
158159
* ## Inference
159160
*
160161
* 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.
163166
*
164167
* ## `$inject` Annotation
165168
* By adding an `$inject` property onto a function the injection parameters can be specified.
@@ -244,6 +247,8 @@ function annotate(fn, strictDi, name) {
244247
* expect(injector.annotate(MyController)).toEqual(['$scope', '$route']);
245248
* ```
246249
*
250+
* You can disallow this method by using strict injection mode.
251+
*
247252
* This method does not work with code minification / obfuscation. For this reason the following
248253
* annotation strategies are supported.
249254
*
@@ -296,6 +301,8 @@ function annotate(fn, strictDi, name) {
296301
* @param {Function|Array.<string|Function>} fn Function for which dependent service names need to
297302
* be retrieved as described above.
298303
*
304+
* @param {boolean=} [strictDi=false] Disallow argument name annotation inference.
305+
*
299306
* @returns {Array.<string>} The names of the services which the function requires.
300307
*/
301308

0 commit comments

Comments
 (0)