Add directive to body

I have a popup directive, and I would like to compile it and add it to the body. Is there an easier way to recompile and add directives to the body.

link: function (scope, element) { $('body').append($compile('html')(scope.new())) } 

I do not want to compile the directive twice, the first time automatically, and the second time manually. If there is a property or parameter that will automatically add directive to the body, this will be great.

+6
source share
1 answer

Why don't you put your custom directive in the right place inside the html page, and then use transclude to swap it with what you specified in the template directive?

0
source

Source: https://habr.com/ru/post/976307/


All Articles