Skip to content

Instantly share code, notes, and snippets.

@eaigner
Last active December 20, 2015 15:38
Show Gist options
  • Save eaigner/6155120 to your computer and use it in GitHub Desktop.
Save eaigner/6155120 to your computer and use it in GitHub Desktop.
Draggable directive for AngularJS
// Usage: ng-draggable="dragFile($event)"
App.directive('ngDraggable', function ($parse) {
return {
restrict: 'A',
link: function (scope, elem, attrs) {
var fn = $parse(attrs.ngDraggable);
elem[0].draggable = true;
elem.bind('dragstart', function (event) {
scope.$apply(function () {
fn(scope, {$event:event});
});
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment