I'm using Angular 2 and ng2-dragula
.
I want to make the drag 'n' drop items in a dragula bag clickable.
This is my app.component.html:
<div id="rootFrame">
<div class="tasksFrame">
<div id="tasksCont" class='container' [dragula]='"first-bag"'>
<div (click)="onClick('ha')">Task 1</div>
<div (click)="onClick('ba')">Task 2</div>
<div (click)="onClick('ca')">Task 3</div>
</div>
</div>
<div class="editorFrame">
<div id="editorCont" class='container' [dragula]='"first-bag"'>
</div>
</div>
<div *ngIf="showProps" class="propertiesFrame">
<form>
Eigenschaft 1<br>
<input type="text" name="property1"><br> Eigenschaft 2<br>
<input type="text" name="property2"><br> Eigenschaft 3<br>
<input type="text" name="property3"><br>
</form>
</div>
</div>
The onClick()
function is never called.
My component app.component.ts looks like this:
import { Component } from '@angular/core';
import { DragulaService } from 'ng2-dragula/ng2-dragula';
@Component({
selector: 'my-app',
templateUrl: 'app/app.component.html',
styleUrls: ['app/app.component.css'],
viewProviders: [DragulaService],
})
export class AppComponent {
private showProps = false;
constructor(private dragulaService: DragulaService) {
dragulaService.setOptions('first-bag', {
removeOnSpill: true,
copy: (el: Element, target: Element, source: Element, sibling: Element): boolean => {
var editorcont = document.getElementById('editorCont');
return !target.contains(editorcont);
},
accepts: (el: Element, target: Element, source: Element, sibling: Element): boolean => {
var taskscont = document.getElementById('tasksCont');
return !target.contains(taskscont); // elements can not be dropped to Tasks Container
},
});
};
onClick(item: String) {
//NOT FIRED
var editorcont = document.getElementById('editorCont');
// if(editorcont.contains(element)){
// this.showProps = true;
// }
// else{
// this.showProps = false;
// }
};
}
I think it's because divs are in a dragula container. But how can I make the divs in the dragula container clickable?