Forked from amatiasq/mq-allow-external-clone.js
Last active
September 8, 2015 20:41
-
-
Save bramus/436039fb314a365f73b5 to your computer and use it in GitHub Desktop.
Directive to allow 3rd party libraries to clone angular nodes.
This file contains hidden or 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