I have a simple directive like this:
myApp.directive('myDirective', function() {
var controller = ['$scope', function($scope) {
function init() {
this.name = "Sim";
this.age = 6;
}
init();
}];
//define the directive object
var directive = {};
directive.controller = controller;
directive.restrict = 'E';
directive.templateUrl = "hello.html";
directive.controllerAs= 'cus';//defining a name to the controller.
return directive;
});
Inside my html template I want to reference controller variables like below (please note the controller above is referenced as cus):
<div>
<div>Name: {{cus.name}}</div>
<div> Age: {{cus.age}}</div>
</div>
Here is my plunk with the problem
Why is this snippet not working?