Once five minutes AngularJS (1)--binding

Source: Internet
Author: User

Reference Angularjs

Need to use ANGULARJS, need to reference Angularjs file

Ng-app

To use angular for page binding, we need to indicate its scope.

In, ng-app= "" means that we are now demonstrating the scope of the angular within the <div> tag. Of course we can also write "ng-app=" on the <body> label. Which tag is written, our angular syntax is supported.

Next, let's look at the effect

It can be seen that the {{,<div>}} is parsed into 4, and the {{* * *}} Outside <div> is output as is.

An expression

In the angular syntax, the contents of {{}} are expressions and can be processed as generic JavaScript syntax.

Binding

We add a <input> on the page, and what you want to <input> enter, what the {{}} expression will show.

Look at the effect

You can see what is entered in the text box, and the contents of the text box are displayed after "Hello", which is the binding in angular

Where the value of Ng-model is the equivalent of defining a variable named name. If the variable does not exist, it is created. The value of the variable is bound on the value of the current <input> tag's values.

{{name}} means to read the value of the variable name that corresponds to Ng-model, which is <input> value.

Example

Add 2 CSS styles to the HTML page, showing red and green, respectively.

Bind the <span> class property to the value of the text box, and now we enter Red,green in the text box to see the effect

Original blog, without permission, please do not reprint.

Once five minutes AngularJS (1)--binding

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.