In many tutorials, I've seen controllers being passed into a directive like this:
.directive("mainRightPanel", function(){
return {
templateUrl: "views/partials/panels/mainRightPanel.html",
controller: function($http, $filter, $scope) {
var info = this;
$scope.authorWorks;
$http.get('test/book_data.json').success(function(data){
$scope.authorWorks= data;
});
},
}
However, I'd like to do it differently. Instead of writing javascript like the above, I'm having problems calling a controller from within the directive, like this
<div ng-app="mainLeftPanelModule" ng-controller="leftPanelController" class="list-group ">
Is this possible? And if it is, is there anything wrong with attaching a controller this way?