JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app='app' ng-controller='OuterCtrl'>
<div ng-controller='dynamicCtrl'>
{{result}}
</div>
</div>
JavaScript
angular.module('app', [])
.controller('OuterCtrl', ['$scope',
function($scope) {
// Instead of hard coding the controller function here,
// how do I resolve the string 'InnerCtrl' to the
// controller function defined below, so it can be
// assigned to this dynamicCtrl property?
$scope.dynamicCtrl = function($scope) {
$scope.result = 'not working yet';
};
//eg:
//$scope.dynamicCtrl = resolveCtrl('InnerCtrl');
}
])
.controller('InnerCtrl', ['$scope', 'service',
function($scope, service) {
$scope.result = service.getMessage();
}
])
.factory('service', function() {
return {
getMessage: function() { return 'working!'; }
};
});