Without the exp
parameter triggers an eval cycle, for this scope and it's 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.
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);
exp
with this
set to the current scope.