Expressions are used to bind application data to HTML. Expressions are written in double brackets like {{expression}}. The behavior in expressions is the same as the ng-bind directive. AngularJS application expressions are pure javascript expressions and output the data they are used there.
Use numbers
<p>Expense on Books : {{cost * quantity}} Rs</p>
Using strings
<p>Hello {{student.firstname + " " + student.lastname}}!</p>
Use object
<p>Roll No: {{student.rollno}}</p>
Using arrays
<p>Marks(Math): {{marks[3]}}</p>
example
The following examples will show all the expressions above.
The testAngularJS.html file code is as follows:
<html><title>AngularJS Expressions</title><body><h1>Sample Application</h1><div ng-app="" ng-init="quantity=1;cost=30; student={firstname:'Mahesh',lastname:'Parashar',rollno:101};marks=[80,90,75,73,60]"> <p>Hello {{student.firstname + " " + student.lastname}}!</p> <p>Expense on Books : {{cost * quantity}} Rs</p> <p>Roll No: {{student.rollno}}</p> <p>Marks(Math): {{marks[3]}}</p></div><script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script></body></html>Output
Open textAngularJS.html in a web browser. The results are as follows:
The above is the information sorting out the AngularJS expressions. We will continue to add relevant information in the future. Thank you for your support to this site!