i试图原型进行一些拖放功能时会遇到NG2-Dragula项目。我想知道如何将以下结构分组为一个" drake"实体?
<div>
<img .../>
<img .../>
<span>...</span>
</div>
当我在DIV中添加[Dragula]时,DIV内部的每个项目都被视为一个单独的可拖动项目。我想将它们结合在一起。
谢谢!
在您的情况下,您需要使用 dragulamodel 。
示例
<div class='wrapper'>
<div class='container' [dragula]='"another-bag"' [dragulaModel]='many'>
<div *ngFor='let text of many' [innerHtml]='text'></div>
</div>
<div class='container' [dragula]='"another-bag"' [dragulaModel]='many2'>
<div *ngFor='let text of many2' [innerHtml]='text'></div>
</div>
</div>
class RepeatExample {
public many: Array<User> = [{'id':123,'name':'stack'},{'id':1234,'name':'stackover'}];
public many2: Array<User> = [];
constructor(private dragulaService: DragulaService) {
dragulaService.dropModel.subscribe((value) => {
this.onDropModel(value.slice(1));
});
dragulaService.removeModel.subscribe((value) => {
this.onRemoveModel(value.slice(1));
});
}
private onDropModel(args) {
let [el, target, source] = args;
// do something else
}
private onRemoveModel(args) {
let [el, source] = args;
// do something else
}
}