AngularBasics (1) [Avatar] Offline
This directive parameter is poorly documented on all sites that I have seen. Does anyone have an example where controllerAs is the only solution to a page design problem?
nlwillia (11) [Avatar] Offline
Re: Anyone with experience of controllerAs?

It's not very clear to me either. I'd like to see the book at least touch on this new pattern and provide some insight into the practical differences, implications and pros/cons.
lsta (1) [Avatar] Offline
Re: Anyone with experience of controllerAs?
If you want to use the latest AngularJS 1.2 features, I recommend ... it also covers the use of var self = this; instead of $scope directly.
Misa (41) [Avatar] Offline
Re: Anyone with experience of controllerAs?
The book referenced in the previous post discusses 'controllerAs':

With AngularJS 1.2 onwards, there is a new syntax, the controllerAs syntax, which allows us to define the variables on the controller instance using the this keyword, and refer to them through the controller from the HTML.

The advantage of this over the earlier syntax is that it makes it explicit in the HTML which variable or function is provided by which controller and which instance of the controller. So with a complicated, nested UI, you don’t need to play a game of “Where’s Waldo?” to find your variables in your code base. It becomes immediately obvious since the controller instance is present in the HTML.

That book also states that using 'controllerAs' is a best practice:

Prefer to use the newer syntax when working with controllers, of defining variables and functions on the controller’s this. That is, use the controllerAs syntax and avoid using the $scope syntax whenever possible. The newer syntax is more concise and easier to understand.

This MEAP badly needs an update to reflect functionality in the current version of AngularJS, and to address issues that have been reported in this forum.