I recently saw this example. This is the first time I have seen a controller inside a directive. This is a normal thing. I thought you should keep these two in different areas for verification:
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>'
};
})
source
share