Angularjs Learning Notes (iii) a simple example of data bidirectional binding _angularjs

Source: Internet
Author: User

Bidirectional binding

Bi-directional binding is the most practical function of ANGULARJS, it saves a lot of code, so that we focus on data and views, do not waste a lot of code in the DOM monitor, data synchronization, about bidirectional update, you can look at the following figure:

Data--> View

Here we only demonstrate how to bind to the view after having the data.

<! DOCTYPE html>

 
 

After clicking the button, the div content becomes dick, the effect is as shown:

View-> Data

In the last example, when we look at the changes in the data, the view changes automatically. So this example is the reverse, the view changes, causing the data to change, then how do we know when the data changes, where we can show the data again through another element.

<! DOCTYPE html>

 
 

View Effects:

Implementation mechanism

Angular the usual DOM events, XHR events, and so on, which triggers the digest process into the angular.

Within the digest process, the traversal is started from Rootscope, and all watcher are checked.

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.