I'm using ui-router in an app that will have dozens of templates. Each template will have a controller.
From what I've been reading, something like this (to setup a route) ought to work:
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('start', {
url: '/start',
templateUrl: 'partials/start.html',
controller: 'StartCtrl'
})
});
That's assuming StartCtrl was previously defined. The app will eventually have dozens of controllers, and don't want the overhead of downloading all of them at once. How can I load a controller only when the template is requested?