I use a pattern for defining my controllers with coffeescript classes and attaching them to the directive (also defined in coffeescript) with controllerAs so I can access the class properties and methods in the template. I also defined the classes using the controller provider. This worked great in angular 1.2.15 but broke when I updated to 1.3.6.
After much debugging, I realized that angular was no longer automatically putting the object instance returned by the coffeescript class onto the scope. The fix is very simple: manually put the instantiated class object on the scope, as show below:
myModule.directive 'cePageHeader', ->
restrict: 'A'
templateUrl: 'shared/ce-page-header.tpl.html'
replace: true
scope: true
controller: 'CePageHeaderDirectiveCtrl as cePageHeaderDirCtrl'
cePageHeaderDirectiveModule.controller 'CePageHeaderDirectiveCtrl',
(UserModel, $scope) ->
$scope.cePageHeaderDirCtrl =
new class CePageHeaderDirectiveCtrl
constructor: ->
@user = UserModel
goHome: ->
console.log "Do something to go home"
Previously, the function simply returned the object created by the class. Adding this one line fixed the problem with 1.3.6:
$scope.cePageHeaderDirCtrl =
BTW, in the template I can access my class object like this:
<a class="navbar-brand" ng-click="cePageHeaderDirCtrl.goHome()">
Go Home
Without the manually assignment to the $scope, $scope.cePageHeaderDirCtrl = {}, an empty object.