I have a directive that has a dynamic template, now I want the directive to have the ability to use different controllers. Is it possible to dynamically assign a controller to a directive? If possible, would that be the same "ctrlr" then passed to the link
function?
.directive('myDirective',['$compile',function($compile){
return {
restrict: 'AE',
replace: true,
transclude: true,
scope: {},
templateUrl: function(el,attrs){
return (angular.isDefined(attrs.template)) ? attrs.template : '/tmpls/default';
},
link : function(scope,el,attrs,ctrlr,transFn){
[... Do Stuff Here ...]
},
controller: [ DYNAMIC CONTROLLER ASSIGNMENT?? ]
};
}]);
require
) or allow the controller to be set directly on the directive? – Davin Tryon Nov 25 '13 at 17:24require
but it won't work for my the situation I'm thinking of, it would mean encapsulating X amount of controllers in X amount of directives to associate with the directive I have in mind. I need to be able to set the controller directly. – m.e.conroy Nov 25 '13 at 19:19