Angularjs expression Explanation and sample code _ANGULARJS

Source: Internet
Author: User


An expression is used for application data binding to HTML. Expressions are written in double brackets just like {{expression}}}. The behavior in an expression is the same as the ng-bind instruction method. ANGULARJS application expressions are pure JavaScript expressions and output the data they are using there.



Working with numbers



<p>expense on books: {Cost * quantity}} rs</p>



Using strings



<p>hello {student.firstname + "" + student.lastname}}!</p>



Working with objects



<p>roll No: {{student.rollno}}</p>



Using arrays



<p>marks (Math): {{marks[3]}}</p>



Example



The following example shows all of the above expressions.



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. See the results as follows:









The above is the ANGULARJS expression of data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.