我已经控制了两个控制器:
<div ng-controller="mainController" ng-init="init({role='widget1'})">
<div ng-controller="ctrlToLoad" ng-init="init({action='put'})" ng-include="aVariable">
</div>
<div ng-controller="ctrlToLoad" ng-init="init({action='delete'})" ng-include="aVariable">
</div>
</div>
目的是使用某个控制器动态地将模板加载到第二个div中,具体取决于我的mainController管理的参数,如:
myApp.controller('mainController', function($scope, $sce, ...) {
if(/*Something*/){
$scope.ctrlToLoad = 'anOtherController'
}
});
myApp.controller('anOtherController', function($scope, $sce, ...) {
// Some jobs...
});