directive not interpolating, in a template string

后端 未结 1 636
挽巷
挽巷 2020-12-21 01:39

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

1条回答
  •  别那么骄傲
    2020-12-21 01:47

    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('

    Remember to inject $compile into the directive.

    0 讨论(0)
提交回复
热议问题