This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 10
10
* current scope.
11
11
*
12
12
* <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.
17
18
* </div>
19
+ *
18
20
* <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:
21
23
* <pre class="prettyprint">
22
- * `<div ng-init="test1 = (data | orderBy:'name' )"></div>`
24
+ * `<div ng-init="test1 = ($index | toString )"></div>`
23
25
* </pre>
24
26
* </div>
25
27
*
You can’t perform that action at this time.
0 commit comments