I use the ng-include directive, which will have a dynamic template and a controller based on some variables in the scope. I currently have such a card.
$scope.map = { 'key1': { controller: Ctrl1, templateUrl: 'tmpl1.html' }, 'key12': { controller: Ctrl2, templateUrl: 'tmpl1.html' } } ... <div ng-include src="map[key].templateUrl" ng-controller="map[key].controller"></div>
However, I would like to discard this map and instead generate templateUrl and the controller via a string. The following returns a controller object, but I need a function that needs to be returned.
var ctrlObj = angular.module('moduleName').controller('ControllerName')
EDIT 1
To clarify:
However, I would like to discard this map and instead generate templateUrl and the controller via the line
Basically, I would like to configure the "subcontrollers" on the page so that it is conditional on the configuration. The main controller, which has the information that all subcontrollers would share: FooCtrl will be the "main" controller, while FooBarCtrl, FooBarSubCtrl will be subcontrollers. My goal would be to create a function that resolves "Bar" to "FooBarCtrl" and this would be enough for the corresponding controller function.
ajpaz source share