I have a grid of lists and am trying to drag and swap the tiles of the grid with each other using ng2-dragula
some.component.html
<md-grid-list rowHeight="200px" id = "cover" >
<md-grid-tile *ngFor="let werbedata of werbedaten"
[class.selected]="werbedata === selectedWerbedata"
[routerLink]="['/flyerdetail',werbedata.artnr]"
[style.background]="'lightblue'" class = "blocks"
[dragula]='"bag-one"'>
<md-list class="example-card">
<md-list-item>Produktname: {{ werbedata.werbetext }}</md-list-item>
<md-list-item>Euro: {{ werbedata.euro }}</md-list-item>
<h3 md-line> Artnr: {{ werbedata.artnr }} </h3>
<p md-line> Werbetext: {{ werbedata.werbetext }} </p>
</md-list>
</md-grid-tile>
</md-grid-list>
some.component.ts
export class FlyerComponent implements OnInit {
werbedaten: WerbeData[];
selectedWerbedata: WerbeData;
constructor( private werbedatenService: WerbeDatenService ){};
...
...
}
My idea was to swap data on the Drop event. Is there a onDrop event that can be added to the HTML like this?
(onDrop) = "swap(data)"
and then do the swap(data:any)
in the component class?
or must I initialize the dragulaservice? Is there a better way to swap instead?
I'm absolutely new to angular and I'm finding this ridiculously difficult to follow along. Any tip would be greatly appreciated?