I have lately switched to using "this" in the controllers and controllerAs in ngRoute and Directives, rather than $scope directly. Although I really enjoy the way the code looks, I have to bind "this" to each function - manually.
Example:
app.controller('mainController', function ($scope, Restangular) {
this.title = '';
$scope.$on('changeTitle', function (event, data) {
this.title = data;
}.bind(this)); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
});
I understand why I have to do that ("this" context constantly changes), is there any better solution (cleaner, usable) I should consider doing?
Thanks.