As title, I'd like to use more than one controller inside some sub-view
routes.js (eg.):
.state("multi",{
url: "/multi",
views: {
"": {
templateUrl: "multipleView.htm",
controller: "MainCTRL",
controllerAs: "ctrl"
},
"viewA@multi": {
templateUrl: "testingBlock.htm",
controller: ["CtrlOne", "CtrlTwo"],
controllerAs: "ctrl"
},
});
Or should I put CtrlOne and CtrlTwo inside a third controller:
function CtrlThree($scope){
CtrlOne($scope);
CtrlOTwo($scope);
}
Why not put the controller in the view instead of specifying it on the routeProvider.
Also do the controllers have a hierarchy or do you want them to all just work on the same level.
Example of what I mentioned above.
<div ng-controller="CtrlOne"> <div ng-controller="CtrlTwo"></div> </div>This would be the html inside the "multipleView.htm" file.