Without the exp
parameter triggers an eval cycle for this scope and its child scopes.
With the exp
parameter, compiles the expression to a function and calls it with this
set
to the current scope and returns the result. In other words, evaluates exp
as angular
expression in the context of the current scope.
var scope = angular.scope(); scope.a = 1; scope.b = 2; expect(scope.$eval('a+b')).toEqual(3); expect(scope.$eval(function(){ return this.a + this.b; })).toEqual(3); scope.$onEval('sum = a+b'); expect(scope.sum).toEqual(undefined); scope.$eval(); expect(scope.sum).toEqual(3);
angular.scope.$eval([exp]);
exp(optional) – {(string|function())} –
An angular expression to be compiled to a function or a js function.
{*}
– The result of calling compiled exp
with this
set to the current scope.