AngularJS: Scope.$watch
Maybe not that much of a pro tip, more of a reminder to self that you can compare the old value to the new value in the $watch listener function to not run the code block when the listener was called due to initialization..
From documentation...
To detect this scenario within the listener fn, you can compare the newVal and oldVal. If these two values are identical (===) then the listener was called due to initialization.
Written by Christoffer Åhrling
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Angularjs
Authors
Related Tags
#angularjs
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#