我们在AngularJS中使用ngDraggable,现在我们想要获取另一个元素所在的元素,我们通过使用ng-drag-data获取drag元素的数据,但我们无法获取其中的数据它掉了下来。它进入ng-repeat
<div class="week" ng-repeat="week in weeks">
<span class="day" cal-week data-week="{{week.weekNumber}}">
<label for="{{week.weekNumber}}">
<input type="checkbox" ng-model="day[week.weekNumber]" id="{{week.weekNumber}}" />{{week.weekNumber}}
</label>
</span>
<span class="day {{day.name}} {{week.weekNumber}}"
cal-date ng-class="{ today: day.isToday, 'different-month': !day.isCurrentMonth}"
data-date="{{day.getTime | date : 'yyyy-MM-dd'}}"
ng-repeat="day in week.days" ng-drag="true" ng-drag-data="'{{day.getTime | date : 'yyyy-MM-dd'}}'" ng-drop="true" ng-drop-success="onDropComplete1($data,$event,ele)" on-dra-end="end()">{{day.number}}</span>
</div>
答案 0 :(得分:1)
我有一个类似的问题,相反,要把元素放在我们下垂&#34;拖动元素&#34;,我将它注入回调evt
// @ ngDrop指令
if (attrs.ngDropSuccess) {
$timeout(function(){
obj.dropedAtEl = angular.element(element);
onDropCallback(scope, {$data: obj.data, $event: obj, $target: scope.$eval(scope.value)});
});
}
现在,您可以通过evt.dropdAtEl
答案 1 :(得分:0)
我是通过在ngDrop指令
中进行更改来实现的$timeout(function(){
onDropCallback(scope{$data:obj.data,$event:obj,$element:element});//add //$element:element
});
这是唯一的方法还是我们有更好的方法?