2016年3月9日 星期三

Angular Expressions, evaluate

from: https://docs.angularjs.org/guide/expression
from: http://ng.malsup.com/#!/$parse-and-$eval
from: http://stackoverflow.com/questions/15671471/angular-js-how-does-eval-work-and-why-is-it-different-from-vanilla-eval
from: http://excellencenodejsblog.com/angularjs-compile-parse-interpolate/


result:






Q: What exactly is $eval doing? Why does it need its own mini parsing language?
Expressions are JavaScript-like code snippets that are usually placed in bindings such as {{ expression }}. Expressions are processed by $parse service.


Q: Why isn't plain old javascript "eval" being used?
If ... 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 $eval() method.

沒有留言:

張貼留言