Contents |
Expression Language
All expressions are evaluated within a context of the current scope. The evaluation is in JavaScript-like format with a few differences.
- No loops, ifs or trinary conditions are allowed. Only basic math operations ( + - / *), assignments, and calling JavaScript functions is allowed.
- If the evaluation is for data-binding purposes, as in {{expression}}, zero or more filters are allowed, separated by the | character. For example {{1+2|currency}}.
Field Access
- name this will retrieve the name key from the scope. If it does not exist, then an undefined is returned.
- a.b this will try to retrieve the a key first and then retrieve the b key on a. Unlike JavaScript, the access will work even if a is undefined or null, resulting in undefined result.
Field Assignment
- name="Jane" this will assign "Jane" to the current scope's name key. If it exist then it will overwrite it.
- model.name="Jane" this will first retrieve the key model on the current scope and then assign "Jane" to the key name on model. Unlike JavaScript, if model does not exist then it will be created automatically.
Filters
- name|json this will retrieve name from the current scope. The result of the name retrieval will be then fed into the json filter, which will turn the name into JSON representation, and the result of the filter will be returned.
Calling JavaScript Functions
- myFunction(name) this will retrieve the name value from the current scope and will then call function myFunction with the name value. The return of the myFunction will contain the scope evaluation.
- $window.myFunction() can be used to access global function declared in JavaScript.
Closuers
Syntax: {:statements}.