I was curious about the $scope.$eval
you so often see in directives, so I checked out the source and found the following in rootScope.js
:
$eval: function(expr, locals) {
return $parse(expr)(this, locals);
},
$parse
appears to be defined by ParseProvider
in parse.js
, which appears to define some kind of mini-syntax of its own (the file is 900 lines long).
My questions are:
What exactly is
$eval
doing? Why does it need its own mini parsing language?Why isn't plain old JavaScript
eval
being used?