diff --git a/a1/README.md b/a1/README.md index edbbef19..678d425b 100644 --- a/a1/README.md +++ b/a1/README.md @@ -403,7 +403,7 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see var vm = this; ``` - Note: When creating watches in a controller using `controller as`, you can watch the `vm.*` member using the following syntax. (Create watches with caution as they add more load to the digest cycle.) + Note: When creating watches in a controller using `controller as`, you can watch the `vm.*` member using the following syntax (Create watches with caution as they add more load to the digest cycle). Also use a function as the first argument of the watcher, so that you remain in the scope of the controller. In this case vm.title would still be accessible when watcher is hit during digest cycle. ```html @@ -414,9 +414,12 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see var vm = this; vm.title = 'Some Title'; - $scope.$watch('vm.title', function(current, original) { - $log.info('vm.title was %s', original); - $log.info('vm.title is now %s', current); + $scope.$watch(function() { + return vm.title; + }, + function(current, original) { + $log.info('vm.title was %s', original); + $log.info('vm.title is now %s', current); }); } ```