Created
May 28, 2015 09:56
Directive to allow 3rd party libraries to clone angular nodes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('my-module') | |
.directive('mqAllowExternalClone', function($compile) { | |
return { | |
link: link, | |
}; | |
function link(scope, elem, attr) { | |
var element = elem[0]; | |
var original = element.cloneNode; | |
element.cloneNode = patch; | |
function patch(deep) { | |
var clone = original.call(element, deep); | |
// You can remove this two lines and the result | |
// will be more or less the same. | |
// In my case I need it for other reasons | |
clone.removeAttribute('mq-allow-external-clone'); | |
clone.cloneNode = patch; | |
$compile(clone)(scope); | |
return clone; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment