Angularjs Introductory tutorial Angularjs expression _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.

Angularjs expression format: {{expression}}

Angularjs expressions can be strings, numbers, operators, and variables

Numeric operation {{1 + 5}}}

String Connection {' abc ' + ' BCD '}}

Variable operation {{firstName + "" + LastName}}, {{quantity * cost}}

Object {{Person.lastname}}}

Array {{points[2]}}

Angularjs Example

1.ANGULARJS Digital

<div ng-app= "" ng-init= "quantity=2;cost=5" >
<p> Total Price: {quantity * cost}}</p>

Previous example output:

Total Price: 10

Code comments:

ng-init= "quantity=2;cost=5"//equivalent to the Var quantity=2,cost=5 in JavaScript;
Use Ng-bind to achieve the same functionality

<div ng-app= "" ng-init= "quantity=1;cost=5" >
<p> Total Price: <span ng-bind= "quantity * cost" ></span ></p>
//The ng-bind here is equivalent to specifying a span of innerHTML

2.Angularjs string

<div ng-app= "" ng-init= "firstname= ' John '; lastname= ' Snow '" >
<p> Name: {{firstName + "" + lastName}}</p >

Output

Name: Jone Snow

3. Angularjs Object

<div ng-app= "ng-init=" person={firstname: ' John ', lastName: ' Snow '} ' >
<p> last name is {{Person.lastname}} </p>

Output

Last Name is Snow

4.AngularJS Array

<div ng-app= "" ng-init= "points=[1,15,19,2,40]" >
<p> The third value is {{points[2]}}</p>
</div>

Output

The third value is 19

The above is a small set to introduce the introduction of the Angularjs introductory course of the ANGULARJS expression of the relevant introduction, I hope to help you!

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.