I'm working on a angular project with angular-ui-route and the use of nested views like:
$stateProvider.state('app', {
url: '/form',
views: {
'p1@modals': {
templateUrl: 'form1.html'
}
'p2@modals': {
templateUrl: 'form2.html',
controller: function($scope) {
//do some thing
}
}
}
})
however, we have several sub views of /form, each of them has a controller, we don't want to put all the controller code in a js file so we write the config as:
$stateProvider.state('app', {
url: '/form',
views: {
'p1@modals': {
templateUrl: 'form1.html'
}
'p2@modals': {
templateUrl: 'form2.html',
controller: 'P2Controller.js'
}
}
})
in P2Controller.js we define the controller as:
define(['app'], function(app) {
app.controller('P2Controller', function($scope) {
});
})
the problem is how can load the P2Controller.js and invoke the controller