I'm trying to extend a directive by passing controllers. I'm able to grab the parent directive's controller through require , but I also want to define a controller on the extended controller.
.directive('smelly', function(){
return {
restrict: 'E',
controller: function(){
this.doWork = function(){ alert('smelly work'); };
},
link: function($scope, $element, $attributes, controller){
$element.bind('click',function(){
controller.doWork();
});
}
};
})
.directive('xtSmelly', function(){
return {
controller: function(){
this.name = "brian";
},
require: 'smelly',
link: function($scope, $element, $attributes, smellyController){
smellyController.doWork = function(){
alert('xt-smelly work by: ' + xtSmellyController.name);
};
}
};
})
HTML
<smelly xt-smelly>click me</smelly>
How can I access xtSmellyController.name?