diff options
| author | Tobias Bosch | 2013-11-07 14:14:57 -0800 | 
|---|---|---|
| committer | Tobias Bosch | 2013-11-07 14:14:57 -0800 | 
| commit | 36621402015485613888158dc7ba29f4ff92a7e2 (patch) | |
| tree | de6bcfa749c8c5db20bc8e46fc9aa666fdafe40d /docs/content/guide/expression.ngdoc | |
| parent | ed8640b96463df8a8f9e4503095bd89916a120c5 (diff) | |
| download | angular.js-36621402015485613888158dc7ba29f4ff92a7e2.tar.bz2 | |
docs(guide/filter): Refactor filter guide docs
This refactors the filter guide docs into a single file.
Also removes out of date references to the fact that Angular used to enhance Arrays while evaluating expressions.
Diffstat (limited to 'docs/content/guide/expression.ngdoc')
| -rw-r--r-- | docs/content/guide/expression.ngdoc | 40 | 
1 files changed, 1 insertions, 39 deletions
| diff --git a/docs/content/guide/expression.ngdoc b/docs/content/guide/expression.ngdoc index 89f48bfd..3499af72 100644 --- a/docs/content/guide/expression.ngdoc +++ b/docs/content/guide/expression.ngdoc @@ -4,12 +4,11 @@  Expressions are JavaScript-like code snippets that are usually placed in bindings such as `{{  expression }}`. Expressions are processed by the {@link api/ng.$parse $parse} -service. +service. Expressions are often post processed using {@link filter filters} to create a more user-friendly format.  For example, these are all valid expressions in angular:    * `1+2` -  * `3*10 | currency`    * `user.name` @@ -29,9 +28,6 @@ You can think of Angular expressions as JavaScript expressions with following di    * **No Control Flow Statements:** you cannot do any of the following in angular expression:      conditionals, loops, or throw. -  * **Filters:** you can pass result of expression evaluations through filter chains. For example -    to convert date object into a local specific human-readable format. -  If, on the other hand, you do want to run arbitrary JavaScript code, you should make it a  controller method and call the method. If you want to `eval()` an angular expression from  JavaScript, use the {@link api/ng.$rootScope.Scope#methods_$eval `$eval()`} method. @@ -150,37 +146,3 @@ You cannot write a control flow statement in an expression. The reason behind th  Angular philosophy that application logic should be in controllers, not in the view. If you need a  conditional, loop, or to throw from a view expression, delegate to a JavaScript method instead. - -## Filters - -When presenting data to the user, you might need to convert the data from its raw format to a -user-friendly format. For example, you might have a data object that needs to be formatted -according to the locale before displaying it to the user. You can pass expressions through a chain -of filters like this: - -       name | uppercase - -The expression evaluator simply passes the value of name to {@link -api/ng.filter:uppercase `uppercase`} filter. - -Chain filters using this syntax: - -       value | filter1 | filter2 - -You can also pass colon-delimited arguments to filters, for example, to display the number 123 -with 2 decimal points: - -       123 | number:2 - -# The $ - -You might be wondering, what is the significance of the $ prefix? It is simply a prefix that -angular uses, to differentiate its API names from others. If angular didn't use $, then evaluating -`a.length()` would return undefined because neither a nor angular define such a property. - -Consider that in a future version of Angular we might choose to add a length method, in which case -the behavior of the expression would change. Worse yet, you, the developer, could create a length -property and then we would have a collision. This problem exists because Angular augments existing -objects with additional behavior. By prefixing its additions with $ we are reserving our namespace -so that angular developers and developers who use Angular can develop in harmony without collisions. - | 
