angularjs - How to dynamically load a controller? -


i've 2 controller ensted:

<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> 

the aim dynamically load template second div controller, depending of parameters managed maincontroller like:

myapp.controller('maincontroller', function($scope, $sce, ...) {     if(/*something*/){         $scope.ctrltoload = 'anothercontroller'     } }); myapp.controller('anothercontroller', function($scope, $sce, ...) {     // jobs... }); 


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -