How can I use multiple angularjs's controller inside a view (or subview of a multi-views)? -


as title, i'd use more 1 controller inside 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 put ctrlone , ctrltwo inside third controller:

function ctrlthree($scope){          ctrlone($scope);          ctrlotwo($scope); } 

why not put controller in view instead of specifying on routeprovider.

also controllers have hierarchy or want them work on same level.

example of mentioned above.

<div ng-controller="ctrlone"> <div ng-controller="ctrltwo"></div> </div>

this html inside "multipleview.htm" file.


Comments