Understand the $apply () and $digest () in angular ()

Source: Internet
Author: User

Category: Angularjs JavaScript 2014-08-20 13:49 13320 people read comments (3) Collection report
Angularjsjavascriptangular
Apply () and apply () and digest () are two core concepts in angularjs, but sometimes they are confusing. To understand how ANGULARJS works, you first need to understand how apply () and apply () and digest () work. This article is intended to explain what apply () and apply () and digest () are, and how to apply them in everyday coding.

Explore apply () and apply () and digest ()
ANGULARJS provides a very cool feature called bidirectional data binding (two-way), which greatly simplifies the way our code is written. Data binding means that when any data in a view changes, the change is automatically fed back to the scope data, meaning that the scope model is automatically updated. Similarly, when the scope model changes, the data in view is updated to the most recent value. So how did Angularjs do that? When you write down an expression such as {{Amodel}}, Angularjs sets a watcher on the scope model behind the scenes to update the view when the data changes. The watcher here are the same as the Watcher you will set in Angularjs:

[JavaScript] View plaincopyprint?
Scope. Scope.watch (' Amodel ', function (NewValue, oldValue) {
Update the DOM with NewValue
});

The second parameter passed into watch () is a callback function that is invoked when the value of the Amodel changes. This callback function will be invoked to update view when the Amodel changes, but there is still

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.