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