Angular js - 拖放:获取拖动项目的ID

时间:2016-01-05 12:37:34

标签: javascript angularjs drag-and-drop

我正在使用以下库:RFC 1034。我不知道如何获取被拖动项目的ID,以及为了更新数据库而删除它的列表ID。

请帮帮我@ user3280132。

view.html

<div class="column" style="">
                    <ul dnd-list="list.milestone_order_id[0]"
                        dnd-allowed-types="list.milestone_order_id[0]."dnd-horizontal-list="true"
                        dnd-inserted="logEvent('Element was inserted at position ' + index, event)" class="itemlist" style="">
                    <li style=""
                        ng-repeat="data in list.milestone_order_id[0]"
                        dnd-draggable="data"
                        dnd-effect-allowed="move"
                        dnd-drop="dropCallback(event, index, item)"
                        dnd-type="data.type"
                        dnd-moved="list.milestone_order_id[0].splice($index, 1);logEvent('Item moved', event)" dnd-copied="logEvent('Item copied', event)"
                        dnd-canceled="logEvent('Drag operation canceled', event)"dnd-dragend="logEvent('Drag operation ended', event)"dnd-selected="models.selected = data"ng-class="{selected: models.selected === data}" ><div class="dashboard-stat blue btn-draggable" style="width: 170px; margin-top:25px;"><div class="visual"><i class="fa fa-comments"></i></div><div class="details"><div class="number">{{data.deal_title}} </div><div class="desc"> {{data.id}} </div></div><a href="#/dashboard/dashboard.html" class="more" data="{{data.id}}" ng-click="view_more(data.id)"> View more<i class="m-icon-swapright m-icon-white"></i></a></div></li></ul></div>

main.js

angular.module("demo").controller("AdvancedDemoController", function($scope) {
 $scope.models = {
    selected: null,
    templates: [
        {type: "deal", id: 2},
        {type: "milestone", id: 1, milestone_order_id:  [[],[],[],[],[]]}
    ],
    dropzones: '' };$scope.models.dropzones = [];
deal_services.get_deals_based_on_milestone().then(function (response) {
    var milestone= angular.fromJson(response.data.status);
    angular.forEach(milestone[0], function(value, key) {
        $scope.models.dropzones.push(value);});});$scope.dragoverCallback = function(event, index, external, type) {
    $scope.logListEvent('dragged over', event, index, external, type);
};$scope.dropCallback = function(event, index, item, external, type, allowedType) {$scope.logListEvent('dropped at', event, index, external, type);
    if (external) {
        if (allowedType === 'itemType' && !item.label) return false;
        if (allowedType === 'containerType' && !angular.isArray(item)) return false;} return item;
};    $scope.logEvent = function(message, event) {
    console.log(message, '(triggered by the following', event.type, 'event)');
    console.log(event);
};   $scope.logListEvent = function(action, event, index, external, type) {
    var message = external ? 'External ' : '';
    message += type + ' element is ' + action + ' position ' + index;
    $scope.logEvent(message, event);
};    $scope.$watch('models', function(model) {
    $scope.modelAsJson = angular.toJson(model, true);

0 个答案:

没有答案