The following section talks about Angularjs DI (Dependency injection), which describes the ANGULARJS expression expression here. Expression refers to a small fragment of JavaScript code that is typically used for binding (binding) such as: {{expression}}. In Angularjs, it is resolved through the $parse service.
$parse usage: $parse (expression);
Parameters: JavaScript code fragment.
Return value: {function (context, locals)}, result of expression compilation:
Context: An embedded expression executes in scope.
Locals: local variable, often used to replace the rewrite context.
The return value also has the Assign property, allowing for an expression to be assigned a value.
The following expressions will all be valid expressions in Angularjs:
1+2
3*10 | Currency
User.Name
Angularjs-expression vs. JavaScript expressions
The Angularjs view expression is somewhat like a JavaScript expression, but is not performed using the JavaScript expression eval () function, which differs from the JavaScript expression as follows:
All attributes are dependent on the scope action. Not JavaScript's global role in Windows.
The expression evaluates to be compatible with null and undefined, while JavaScript throws a Nullpointerexceptions exception.
No control process statements, conditions, loops throw.
filter, redundant ANGULARJS expression calculation results can be transformed through the filter format, | expressions, such as time, currency, number format.
Note: For angularjs expressions, the $eval () method can be used to parse execution.
Demo
Html:
<!doctype html>