Angularjs's study notes (ii)

Source: Internet
Author: User

Only to see for yourself.

AngularJSAn expression

Angularjs uses an expression to bind data to HTML.

The AngularJS expression is written in double curly braces:{{expression}}.

AngularJS expressions bind data to HTML, which is similar to the ng-bind directive.

AngularJS will "output" the data where the expression is written.

AngularJS Expressions are much like JavaScript expressions : They can contain literals, operators, and variables

Numbers: {{5*5}} and Ng-bind= "5*5" are the same, others are the same, such as strings, objects, etc.

String: <div ng-app= "" ng-init= "firstname= ' John '; lastname= ' Doe '" >

<p> Name: {{firstName + "" + lastName}}</p>

</div>

Object: Just like the JS object.

<div ng-app= "" ng-init= "Person={firstname: ' John ', lastName: ' Doe '} ' >

<p> Last name is {{Person.lastname}}</p>

</div>

Arrays: Like the JS array, use [] to tune out the line

<div ng-app= "" ng-init= "points=[1,15,19,2,40]" >

<p> The third value is {{points[2]}}</p>

</div>

AngularJS Expressions and JavaScript expressions

Similar to JavaScript expressions, AngularJS expressions can contain letters, operators, and variables.

Unlike JavaScript expressions, AngularJS expressions can be written in HTML.

Unlike JavaScript expressions, AngularJS expressions do not support conditional judgments, loops, and exceptions.

Unlike JavaScript expressions, AngularJS expressions support filters.

AngularJS directive

AngularJS extends HTML through new attributes called directives .

AngularJS adds functionality to your app with built-in instructions.

AngularJS allows you to customize the instructions.

The AngularJS directive is an extended HTML attribute with the prefix ng-.

The ng-app instruction Initializes an AngularJS application.

The ng-init instruction initializes the application data.

The ng-model directive binds the element value (such as the value of the input field) to the application.

Ng-app is telling this to be the owner of the Angularjs application. You can have multiple Ng-app in a Web page.

To be Continued ...

Angularjs's study notes (ii)

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.