AngularJS - Get controller function by string

I am using the ng-include directive that will have a dynamic template and controller based on some variables in the scope. Currently I have a map like this.

$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 the templateUrl and controller via a string. The following returns the controller object but I need the function 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 the templateUrl and controller via a string

Basically I would to set up 'sub-controllers' on a page a way so that it would be convention over configuration. A master controller that has information that all the sub-controllers would share: FooCtrl would be the 'master' controller while FooBarCtrl, FooBarSubCtrl would be sub-controllers. My goal would be to make a function that would resolve "Bar" to "FooBarCtrl" and from that grab the appropriate controller function.

I don't see any trivial way of achieving this, however I can imagine two potential solutions:

  1. Modify ngInclude directive so that it takes the src expression, parses it to get the controller name (template Foo.html => controller FooCtrl) and sets the controller on the element like it is done in ngView (https://github.com/angular/angular.js/blob/master/src/ng/directive/ngView.js#L149):

    controller = $controller(current.controller, {$scope: lastScope});
    element.contents().data('$ngControllerController', controller);
    
  2. Create new directive e.g. "ajpaz-controller" that watches the src expression and links the controller to the element the same way as in point 1. The obvious advantage is that it can be done without modifying the original ng-include. It would work like this

    <div ng-include src="templateUrl" ajpaz-controller>
    

So you would have to only keep the current templateUrl in your parent controller. Hope that makes sense;)

From the following stackoverflow link. I believe it has the answer to this question.

Using Angular Controllers created with angular.module().controller()

Given:

angular.module('App.controllers', [])
    .controller('home', function () {
        $scope.property = true;
    }]);

Answer:

// Try using a string identifier.

routeProvider.when('/', {templateUrl: 'partials/home.html', controller: 'home'});