Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 010d9b6

Browse files
docs(ngInit): relaxed the warning notice
1 parent 122ab07 commit 010d9b6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/ng/directive/ngInit.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
* current scope.
1111
*
1212
* <div class="alert alert-danger">
13-
* The only appropriate use of `ngInit` is for aliasing special properties of
14-
* {@link ng.directive:ngRepeat `ngRepeat`}, as seen in the demo below. Besides this case, you
15-
* should use {@link guide/controller controllers} rather than `ngInit`
16-
* to initialize values on a scope.
13+
* This directive can be abused to add unnecesary amounts of logic into your templates.
14+
* There are only a few appropriate uses of `ngInit`, such as for aliasing special properties of
15+
* {@link ng.directive:ngRepeat `ngRepeat`}, as seen in the demo below; and for injecting data via
16+
* server side scripting. Besides these few cases, you should use {@link guide/controller controllers}
17+
* rather than `ngInit` to initialize values on a scope.
1718
* </div>
19+
*
1820
* <div class="alert alert-warning">
19-
* **Note**: If you have assignment in `ngInit` along with {@link ng.$filter `$filter`}, make
20-
* sure you have parenthesis for correct precedence:
21+
* **Note**: If you have assignment in `ngInit` along with a {@link ng.$filter `filter`}, make
22+
* sure you have parentheses to ensure correct operator precedence:
2123
* <pre class="prettyprint">
22-
* `<div ng-init="test1 = (data | orderBy:'name')"></div>`
24+
* `<div ng-init="test1 = ($index | toString)"></div>`
2325
* </pre>
2426
* </div>
2527
*

0 commit comments

Comments
 (0)