I am using controllerAs on my directive and used bindToController.
But bindToController parameter is undefined on controller. DEMO
var myApp = angular.module('myApp',[]);
myApp.controller('MyController', function($scope){
$scope.change = function(){
$scope.fullname = 'Brian Kim';
}
});
myApp.directive('myDirective', function () {
return {
restrict: 'E',
scope: {
name: '='
},
controller: function () {
console.log(this.name); // undefined
},
controllerAs: 'ctrl',
bindToController: true,
template: '{{ctrl.name}}',
};
});