1

我是 angularJS 的初学者。在容器中各个 div 的拖放完成后,我试图获取位置的变化。我尝试了他们网站上给出的一些代码片段,但找不到解决方案。

以下是我使用的代码片段:

使用的模板:

<div class='container' dragula='"first-bag"'>
    <div>You can move these elements between these two containers</div>
    <div>Moving them anywhere else isn't quite possible</div>
    <div>There's also the possibility of moving elements around in the same container, changing their position</div>
</div>

在我的控制器中:

$scope.$on('first-bag.drag', function (e, el) {
    el.removeClass('ex-moved');
    console.log(e);
    console.log(el);        
});

$scope.$on('first-bag.drop', function (e, el) {
    el.addClass('ex-moved');
    console.log(e);
    console.log(el.id);  
});

$scope.$on('first-bag.over', function (e, el, container) {
    container.addClass('ex-over');
    console.log(e);
    console.log(el);       
});

$scope.$on('first-bag.out', function (e, el, container) {
    container.removeClass('ex-over');
    console.log(e);
    console.log(el);
});

如果我在正确的道路上或者我在任何地方出错,有人可以指导我。

4

0 回答 0