I'm interested in exploring the various scenarios where these two methods of creating a controller can be used:
Using ngController:
myApp.controller('myController', ['$scope', function ( $scope ) {
}]);
Creating the controller within a directive using the controller attribute:
myApp.directive ( 'myDirective', [ '$window', function( $window ) {
return {
restrict: 'A',
controller: [ '$scope', function( $scope ) {
}],
link: function( scope, element, attrs ) {
}
};
}]);
Are there any specific reasons for not constructing the controller within a directive if they are both applied to the same element?
Could it depend on the complexity and usage frequency of the controller?