mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 01:25:16 +00:00
27 lines
640 B
JavaScript
27 lines
640 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();
|
|
}
|
|
});
|
|
},
|
|
}));
|
|
}
|
|
|
|
init.init = true;
|
|
|