Skip to content

Commit

Permalink
added watches for controller as
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpapa committed Sep 21, 2014
1 parent b019c65 commit 045293d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ 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.)

```javascript
$scope.$watch('vm.title', function(current, original) {
$log.info('vm.title was %s', original);
$log.info('vm.title is now %s', current);
});
```

- **Bindable Members Up Top**: Place bindable members at the top of the controller, alphabetized, and not spread through the controller code.

*Why?*: Placing bindable members at the top makes it easy to read and helps you instantly identify which members of the controller can be bound and used in the View.
Expand Down

0 comments on commit 045293d

Please sign in to comment.