AngularJS Tutorial - AngularJS Expressions

Expressions are similar to an eval function in Javascript.

AngularJS expressions have the following syntax:

{{ expression }}

The {{ }} notation is for showing a variable attached to a $scope. All expressions are executed in the context of the scope and have access to local $scope variables.


The following code shows how to do simple math calculation in expressions.

<!DOCTYPE html>
<html ng-app>
<script src=""></script>
</head><!-- w  ww .  java 2  s  .c o  m-->

The code above is rendered as follows:


AngularJS expressions, which do not allow for any control flow functions (if/else), can accept a filter and filter chains.

An expression doesn't throw errors if it results in a TypeError or a ReferenceError.