Closed wonderfan closed 8 years ago
The first parameter is context – this is an object any expressions embedded in the strings are evaluated against (typically a scope object). The second parameter is locals – this is an JavaScript object with local variables, useful for overriding values in context.
It is important to understand that $parse can be invoked once and its result (pre-compiled expression) can be used multiple times with different context (and locals).
$eval is a method on a scope. It executes an expression on the current scope and returns the result.
$interpolate. By means of $interpolate you can do on-the-fly templating like well-known template engines Handlebars or Hogan do that.
The source code: https://github.com/angular/angular.js/blob/master/src/ng/parse.js
The $parse compiles an expression to a function which can be then invoked with a context and locals in order to retrieve the expression’s value.