I have a rather complicated controller (about 3 thousand lines of code) that the panel demonstrates. The controller contains many diagrams, grid tables, etc.
For example, I moved the table table logic to a lower directive named wmGridActionItems . Note that it uses the parent scope:
app.directive('wmGridActionItems', ['$rootScope', '$timeout', function ($rootScope, $timeout) { return { restrict: 'E', templateUrl: 'views/grid-action-items.html', link: function (scope, elem, attrs) {
and HTML:
<div ui-grid="gridActionItemsOptions" ui-grid-auto-resize ui-grid-pagination ui-grid-selection ui-grid-auto-resize ui-grid-resize-columns> </div>
So basically the controller HTML I just write: <wm-grid-action-items></wm-grid-action-items>
I am unable to use this directive elsewhere, but at least I am dividing my BIG controller into a few small directives that will help me deal with the toolbar.
Am I doing something wrong? Is this a good practice? Does Angular have other approaches to solve this problem?
EDIT
This is my $StateProvider to display the panel:
$stateProvider .state('sidemenu.dash', { url: '/dshmngr', abstract: true, views: { 'content': { templateUrl: 'views/dashboard/dashboard_manager.html', controller: 'DashboardMngrCtrl' } } }) .state('sidemenu.dash.main', { url: '/main', views: { 'content': { templateUrl: 'views/dashboard/dashboard-main.html', controller: 'DashboardNewCtrl' } } }) .state('sidemenu.dash.drill', { url: '/drill/:type', views: { 'content': { templateUrl: 'views/dashboard/dashboard-tag-details.html', controller: 'DashboardDetailedCtrl' } } })
Thanks,