Explain the expressions used in Angularjs

Source: Internet
Author: User


This article mainly introduces the use of the expressions in the detailed angularjs, including the manipulation of various objects such as numbers and strings, and the friends who need them can refer to the following



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:


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.