Holla Tech - Learn
AngularJS: Expressions
 

An expression is usually wrapped inside double curly braces, such as {{ expression }}. AngularJS evaluates the expression and produces a result. Expressions can contain literals, operators, and properties.

Let’s create an AngularJS app with an expression:  

<!DOCTYPE HTML>
<html ng-app>
<head>
  <script src=“https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js”></script>
</head>
<body>
  <p> {{ 2+2 }} </p>
</body>
</html> 

 

The code above produces the output 4, because AngularJS evaluates the expression and returns the result.

Notice the ng-app attribute in the <html> tag. This is called a directive, and it defines that this is an AngularJS application. If we remove that directive, the expression will not be evaluated.

There are a number of other directives, which allow AngularJS to attach specified behavior to HTML elements. We will learn about them in the coming lessons.

NOTE!
AngularJS expressions do not support conditionals, loops, and exceptions, while JavaScript expressions do.

BACK NEXT

CLICK ON THE BUTTON BELOW TO RETURN TO THE AngularJS MAIN COURSE PAGE. 

AngularJS MAIN COURSE PAGE

 


© License: All Rights Reserved 


CONTACT HOLLA TECH – LEARN SUPPORT