我有一个带有打字稿的angular2应用程序.我使用
ng2-dragula来制作拖放应用程序.
我需要检查条件,如果条件为假则恢复拖动,我知道从here开始,revertOnSpill revertOnSpill:true可以将元素放回到第一位.
但是,我不知道在ng2-dragula中怎么可能.
我在onDrop中赞美它.这是代码
constructor() { dragulaService.drop.subscribe((value) => { this.onDrop(value.slice(1)); }); dragulaService.setOptions('second-bag',{ removeOnSpill: true }); } private onDrop(args) { bla bla bla if(err.status=="404") this.dragulaService.removeModel; // this.dragulaService.cancel; also tried but did not work }
这是HTML代码:
<div id="toPlay" class="playBox roundedBox" [dragula]="'second-bag'"> <img class="w3-animate-top" [src]="sax_path" alt="sax" id="saxsophone"/> <img class="w3-animate-top" [src]="drum_path" alt="drum" id="drum"/> </div> <div id="scene" [dragula]="'second-bag'"> </div>
Package.json是:
"dependencies": { "dragula": "^3.7.2" },"peerDependencies": { "@angular/common": "^2.0.0","@angular/core": "^2.0.0","@angular/compiler": "^2.0.0","@angular/forms": "^2.0.0" },"devDependencies": { "angular-cli": "1.0.0-beta.22-1","typescript": "2.0.10" }
问题是,我不知道如何取消掉落?