$watch function expressions

- [Instructor] There is another way to use…the dollar watch first argument.…The thing we watch can be a string with an expression…like we've seen before, like we've watched vm.force.…Or it can be a function that returns value.…When we use a function that returns a value…the return value will be the value that is watched.…So for example if we want to watch if the force is even…or odd, I'll just write a new function that returns…vm.force modular two equals equals zero.…

And now the new value and the old value arguments…are going to be true or false, depends on what this…function returns.…I am going to change my console log statement to reflect…whether the force is even or odd.…If the new value is true, it means the force is even.…And if it's false, it means the force is odd.…Let's go back to the app and see what happens.…Whenever I change the value, for example I'm going to…add the one here then we're going to see a listener…code and the force is going to be odd.…

If I'm going to add another one here the force is…

Resume Transcript Auto-Scroll

Author

Released

8/3/2017

Scope is at the heart of the AngularJS data-binding story, weaving together the controller (JavaScript) and the view (HTML) of a web application. The digest cycle is the scope's monitor, which watches for changes and updates the view. The way you edit the scope and call the digest cycle—using functions such as $watch(), $digest(), and $apply()—can make a huge difference in the reliability and performance of large applications. Companies are looking for AngularJS developers who can understand, execute, and troubleshoot these functions.