ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

Is it possible to define multiple controllers for a particular view?

Open beninfobelt opened this issue 13 years ago • 3 comments

I know how to define one but what if I want to use multiple controllers for better organization?

.state('dashboard', { parent: 'template', url: '/dashboard', views: { "content": { templateUrl: '/views/partials/dashboard.html' }, "menu": { templateUrl: '/views/partials/graphs-menu.html', controller: 'projectsCtrl' }, "sidebar": { templateUrl: '/views/partials/activity-monitor.html', controller: 'activityMonitorCtrl' }

beninfobelt avatar Oct 23 '13 14:10 beninfobelt

Nope, just one each. If you want multiple controllers to apply to the same content area, use nested views.

nateabele avatar Oct 23 '13 14:10 nateabele

Also, what if I don't use views for a particular state?

  .state('template', {
abstract: true,
url: '/home',
templateUrl: '/views/partials/template.html',
controller: 'templateCtrl'

beninfobelt avatar Oct 23 '13 14:10 beninfobelt

For open-ended help and discussion questions, please see the links provided in the readme. The GitHub issue tracker is not a support forum. Thanks.

nateabele avatar Oct 23 '13 14:10 nateabele