我有一個angular2
應用程序與typescript
。我正在使用ng2-dragula進行拖放應用程序。Dragula:恢復在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"
}
問題是,我不知道如何取消下降?
是否使用dragula或NG2-dragula? – Meir
你也有ng2-dragula嗎?如果沒有,他們有一個專門用於angular2的包:https://github.com/valor-software/ng2-dragula – Meir
從來沒有做過,但我認爲'accept'方法(請參閱https:// github .com/bevacqua/dragula)就是你之後的 – Meir