Angularjs learning notes-two-way data binding _ AngularJS

Source: Internet
Author: User
AngularJS uses dirty checking in the $ scope variable to implement bidirectional data binding. Unlike the setter and getter dynamic facilities in the two-way binding of Ember. js data, the dirty check allows AngularJS to monitor variables that exist or do not exist. This time, we will detail angular's two-way data binding.

1. Simple example

This example has already been shown in section 1.

The result is that the content entered in the input box is changed accordingly. This enables two-way data binding.

II. use of value expressions and ng-bind

Let's look at another example. click here. in the first example in the text, {greeting. text }}and {text} are a value expression, but if you refresh the page, you will find such a problem, that is, sometimes "{greeting. text }}{ {text} ", how can we solve this problem?

The ng-bind command is used to bind a data expression.

For example

{{greeting.text}} {{text}}

Changed:

"

";

After this correction, the page will be refreshed without any undesired strings.

However, using commands is always less efficient than using expressions directly, so we have summarized a common rule: in general, index uses ng-bind, the format of '{{}}' is used in subsequent templates.

III. typical scenario of bidirectional binding-form

Let's take a look at the content of form.html:

 
  
  

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.