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

Commit 24eb528

Browse files
Alexseypetebacondarwin
authored andcommitted
docs(guide/expression): update diff list between JavaScript and Angular expressions
add paragraphs about function declaration, comma and void operators and RegExp to the diff list in the beginning of articule Closes #10418 Closes #10452
1 parent d161cc6 commit 24eb528

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

docs/content/guide/expression.ngdoc

+13-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@ Angular expressions are like JavaScript expressions with the following differenc
2626
* **Forgiving:** In JavaScript, trying to evaluate undefined properties generates `ReferenceError`
2727
or `TypeError`. In Angular, expression evaluation is forgiving to `undefined` and `null`.
2828

29-
* **No Control Flow Statements:** you cannot use the following in an Angular expression:
29+
* **No Control Flow Statements:** You cannot use the following in an Angular expression:
3030
conditionals, loops, or exceptions.
31+
32+
* **No Function Declarations:** You cannot decleare functions in an Angular expression.
33+
Even inside `ng-init` directive
34+
35+
* **No RegExp Creation With Literal Notation:** You cannot create regular expressions
36+
in an Angular expression.
37+
38+
* **No Comma And Void Operators:** You cannot use `,` or `void` in an Angular expression.
3139

3240
* **Filters:** You can use {@link guide/filter filters} within expressions to format data before
3341
displaying it.
@@ -164,11 +172,11 @@ expression. The reason behind this is core to the Angular philosophy that applic
164172
be in controllers, not the views. If you need a real conditional, loop, or to throw from a view
165173
expression, delegate to a JavaScript method instead.
166174

167-
## No RegExp creation with literal notation
175+
## No function declarations or RegExp creation with literal notation
168176

169-
You can't create regular expressions from within AngularJS expressions. This is to avoid complex
170-
model transformation logic inside templates. Such logic is better placed in a controller or in a dedicated
171-
filter where it can be tested properly.
177+
You can't declare functions or create regular expressions from within AngularJS expressions. This is
178+
to avoid complex model transformation logic inside templates. Such logic is better placed in a
179+
controller or in a dedicated filter where it can be tested properly.
172180

173181
## `$event`
174182

0 commit comments

Comments
 (0)