Reputation: 795
In my AngularJS application I have a textarea with some text and a list of available keywords.
When the user drags a specific word and drop it in inside the text area the word should be inserted in the drop position.
For simple demonstration - try to select some text in your browser and drag it to any input field you have in your page - the text is inserted exactly at the drop position.
I want to achieve the same functionality. How can I?
For working with HTML5 DND and angular I used the directives from this fiddle - http://jsfiddle.net/jgoemat/NWnF8/
module.directive('draggable', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element[0].addEventListener('dragstart', scope.handleDragStart, false);
element[0].addEventListener('dragend', scope.handleDragEnd, false);
}
}
});
module.directive('droppable', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element[0].addEventListener('drop', scope.handleDrop, false);
element[0].addEventListener('dragover', scope.handleDragOver, false);
}
}
});
Upvotes: 1
Views: 1980
Reputation: 41
$scope.$digest();
Read more about $digest
. https://docs.angularjs.org/api/ng/type/$rootScope.Scope
Upvotes: 3