khalil _diouri
khalil _diouri

Reputation: 821

How Get Id of Draggable Element Angular2

I need to get an ID of the draggable Element

I'm using ng2_dnd I tried in method OnDragStart to get ID like this

  <li dnd-draggable [dropZones]="['doc']" [dragEnabled]="true" id="id01" (onDragStart)="getDraggableId($event)">Div 12</li>

and in typescript side I call my method getDraggableId

getDraggableId(event){
        this.draggableIdGrid = $(event).attr('id');
        console.log("get draggablke  " + this.draggableIdGrid);

    }

should I use ElementRef ?

thanks

Upvotes: 1

Views: 1055

Answers (1)

Maximilian Riegler
Maximilian Riegler

Reputation: 23506

Looking at the source code I came to the conclusion that this should work:

getDraggableId(event){
    this.draggableIdGrid = event.mouseEvent.target.id;
    console.log("get draggable  " + this.draggableIdGrid);
}

Upvotes: 2

Related Questions