I\'m trying to conditionally build a template. I got a k2plugin directive with some divs and spans. According to the pluginui attribute, I want to insert another directive a
I don't think Angular will interpolate something into a directive name. {{}}s (automatically) set up a $watch. When the $watch notices a change, it will update the view, but it won't call $compile, which is what I think needs to happen here.
So, I would try generating the HTML/template in the directive's link function and then $compile it. Something like:
scope.$watch('pluginui', function(newValue) {
var jqLiteWrappedElement = angular.element('<div ' + newValue + ' width=...');
element.replaceWith(jqLiteWrappedElement);
$compile(jqLiteWrappedElement)(scope);
})
Remember to inject $compile
into the directive.