Skip to content Skip to sidebar Skip to footer

Is It Possible To Compile A Modified Directive Template Without Using Transclusion?

I have been trying to use transclusion to create a directive which makes two copies of it's contents and appends them inside the original template. I have failed in my attempts to

Solution 1:

I got your transcluded example working. See here.

I had to call the below to get it working.

$compile(clone)(scope.$parent);

For the ngTransclude:orphan problem, in this version by compiling just the form elements it works when the child transclude is outside of the form.


Solution 2:

This plunker was prior to Angular 1.5 which introduce Tranclusion.

link: function(scope, element) {
      if (!element.find('ng-transclude').children().length) {
        element.find('button').append('<b style="color: red">Button1</b>');
      }
    }

Plunker


Post a Comment for "Is It Possible To Compile A Modified Directive Template Without Using Transclusion?"