diff --git a/dragon-drop.js b/dragon-drop.js index 3222953..7ea1684 100644 --- a/dragon-drop.js +++ b/dragon-drop.js @@ -145,12 +145,17 @@ angular.module('btford.dragon-drop', []). if (dropArea.length > 0) { var expression = dropArea.attr('btf-dragon'); + var dropCallback = dropArea.attr('btf-dragon-drop'); var targetScope = dropArea.scope(); var match = expression.match(/^\s*(.+)\s+in\s+(.*?)\s*$/); var targetList = targetScope.$eval(match[2]); + var targetCallback = targetScope.$eval(dropCallback); targetScope.$apply(function () { add(targetList, dragValue, dragKey); + if (targetCallback && angular.isFunction(targetCallback)) { + targetCallback(dragValue, dragKey); + } }); } else if (!dragDuplicate) { // no dropArea here diff --git a/example.html b/example.html index b8bbad0..78a51d8 100644 --- a/example.html +++ b/example.html @@ -27,7 +27,7 @@

Things

Other Things

-
{{thing}}
+
{{thing}}
@@ -53,6 +53,9 @@

Other Things

controller('MainCtrl', function ($scope) { $scope.things = ['one', 'two', 'three']; $scope.otherThings = []; + $scope.dropCallback = function(value, key) { + console.log('Value:', value, 'Key:', key); + } });