Dynamic transclude value in Directive

1.2k Views Asked by At

I have a directive like this:

platform.directive("permission", function(){
  return {
   restrict: 'E',
   transclude: false,
   template: ""
  }
});

And i want to create a var for transclude value and change depend on conditions, How can i do that?

1

There are 1 best solutions below

0
On

First, set transclude: true. This will tell angular to allow wrapping your directive outside of arbitrary content, while allowing access to the parent scope.

Normally you would use ngTransclude to tell angular where to put the transcluded content. Because you want more control, you would have to define a transclude function yourself, as part of your directive controller, or compile functions.

For more info, see the transclusion documentation.