Online Snippets Library

AngularJS Expressions With Example

AngularJS Expressions are used to binding data to HTML such as {{ expression }}. AngularJS expressions contain literals, operators, and variables.

Example

HTML
<html>  
<head>  
<title>AngularJS Expression Example</title>  
<script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">  
</script>  
</head>  
<body>  
<div ng-app=''>  
<h3>AngularJS Numbers </h3>
<div ng-init="a=10;b=1">  
Total is: {{ a + b }}  
</div>  
<h3>AngularJS Strings </h3>
<div ng-init="firstName='Max';lastName='Joe'">  
Full Name is : {{ firstName + " " + lastName }}
</div> 
<h3>AngularJS Objects </h3> 
<div ng-init="student={ name:'Max', email:'[email protected]'}">  
Expression Result: {{ student.name +"   "+ student.email }}  
</div> 
<h3>AngularJS Arrays </h3>
<div ng-app="" ng-init="points=[1,3,5,7,9]">
<p>The third result is <span ng-bind="points[2]"></span></p>
</div> 
</div>  
</body>  
</html>