I recently saw this example. It's the first time I have seen a controller inside a directive. Is this a normal thing to do. I thought you were supposed to keep these two in different areas for testability:
myModule.directive('myComponent', function(mySharedService) {
return {
restrict: 'E',
controller: function($scope, $attrs, mySharedService) {
$scope.$on('handleBroadcast', function() {
$scope.message = 'Directive: ' + mySharedService.message;
});
},
replace: true,
template: '<input>'
};
})