Skip to content

Commit 2cb0318

Browse files
committed
docs(ngInit): clarify when it's okay to use ngInit
Closes angular#10489
1 parent 2c8bfd8 commit 2cb0318

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/ng/directive/ngInit.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@
55
* @name ngInit
66
* @restrict AC
77
* @priority 450
8+
* @element ANY
9+
*
10+
* @param {expression} ngInit {@link guide/expression Expression} to eval.
811
*
912
* @description
1013
* The `ngInit` directive allows you to evaluate an expression in the
1114
* current scope.
1215
*
1316
* <div class="alert alert-danger">
1417
* This directive can be abused to add unnecessary amounts of logic into your templates.
15-
* There are only a few appropriate uses of `ngInit`, such as for aliasing special properties of
16-
* {@link ng.directive:ngRepeat `ngRepeat`}, as seen in the demo below; and for injecting data via
17-
* server side scripting. Besides these few cases, you should use {@link guide/controller controllers}
18-
* rather than `ngInit` to initialize values on a scope.
18+
* There are only a few appropriate uses of `ngInit`:
19+
* <ul>
20+
* <li>aliasing special properties of {@link ng.directive:ngRepeat `ngRepeat`},
21+
* as seen in the demo below.</li>
22+
* <li>initializing data during development, or for examples, as seen throughout these docs.</li>
23+
* <li>injecting data via server side scripting.</li>
24+
* </ul>
25+
*
26+
* Besides these few cases, you should use {@link guide/component Components} or
27+
* {@link guide/controller Controllers} rather than `ngInit` to initialize values on a scope.
1928
* </div>
2029
*
2130
* <div class="alert alert-warning">
@@ -26,11 +35,6 @@
2635
* </pre>
2736
* </div>
2837
*
29-
* @priority 450
30-
*
31-
* @element ANY
32-
* @param {expression} ngInit {@link guide/expression Expression} to eval.
33-
*
3438
* @example
3539
<example module="initExample" name="ng-init">
3640
<file name="index.html">

0 commit comments

Comments
 (0)