If I want to assign dynamic controller, I can do the following:
<div ng-controller="MainController">
<div ng-controller="dynamicController"></div>
</div>
function MainController($scope){
$scope.dynamicController = MyCtrl;
$scope.instanceName = "ctrl"; // we'll use this later
}
function MyCtrl(){}
What can I do to make this work with the new "controller as" syntax?
This works fine: <div ng-controller="dynamicController as ctrl"></div>
But how to make ctrl dynamic too? Let's say I want it to have a name that $scope.instanceName holds.
Fiddle: http://jsfiddle.net/ftza67or/2/
There is an idea to make a custom directive that will create and compile html string, but it's an ugly way, let's pretend it does not exist.
$controllerservice. Using the name of the function seems like trouble, I'd try to use the name of the registered controller.