# angular.scope.$eval

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

## Description

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.

### Example

             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);

## Usage

    angular.scope.$eval([exp]);

### Parameters

- `exp(optional) – {(string|function())} –`

  An angular expression to be compiled to a function or a js function.

### Returns

`{*}` –

The result of calling compiled `exp` with `this` set to the current scope.