redash/client/app/components/transclude-replace.js
Levko Kravets 143db90a50 Fix query page header (#3046)
* getredash/redash#3017 Improve query page header

* getredash/redash#3017 Resolve conflicts

* getredash/redash#3017 CR1 (fix margins/paddings)
2018-11-20 18:48:41 +02:00

24 lines
620 B
JavaScript

export default function init(ngModule) {
ngModule.directive('ngTranscludeReplace', $log => ({
terminal: true,
restrict: 'EA',
link: ($scope, $element, $attr, ctrl, transclude) => {
if (!transclude) {
$log.error(
'orphan',
'Illegal use of ngTranscludeReplace directive in the template! ' +
'No parent directive that requires a transclusion found.',
);
return;
}
transclude((clone) => {
if (clone.length) {
$element.replaceWith(clone);
} else {
$element.remove();
}
});
},
}));
}