bevacqua / angularjs-dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/angularjs-dragula
MIT License
509 stars 110 forks source link

Inserting dynamic content into a copied element #121

Open johnpolitowski opened 6 years ago

johnpolitowski commented 6 years ago

I'm trying to insert some dynamic content into to copied elements, such as unique id, and a directive depending on what is dragged. Is that possible?

johnpolitowski commented 6 years ago

Actually I figured it out. It can be accessed by innerHTML of target

    $scope.$on('script-editor.drop', function (el, target, source, sibling) {
        console.log('target', target);
        angular.forEach(target[0].classList, function(className){
            if(className == 'template'){
                //console.log('got one!');
                target[0].innerHTML = 'boombap';
            }
        });
    });