How to use $watch in AngularJs
$watch is an important feature present in AngularJs. It can be used to keep a watch on any value and trgiiger a function when that value changes.
In the below snippet, a watch is kept on the 'DollarRate' object present in the scope of the controller where this watch is defined.
$scope.$watch('DollarRate', function(newValue, oldValue) {
// do something with the new or the old value.
});
Written by Yasser Shaikh
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Angularjs
Authors
Related Tags
#angularjs
Did you know?
AngularJS pages are long-lived browser apps with the same script risk as a newer single-page app. Third-party code in the template can read forms and values rendered on the page.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#