Issue
There is a method definition in Angular CdkDrag API.

But how to call it in code?
I have tried like below but error is happening. What is the right way to use this kind of methods?
export class DragableComponent implements OnInit {
_dragRef: DragRef<CdkDrag>;
this._dragRef.getFreeDragPosition();
Solution
This is a method that is called on an instance of CdkDrag. One of the ways to get the instance is to use cdkDragEnded output event.
Sample code:
public onDragEnded(event: CdkDragEnd): void {
console.log(event.source.getFreeDragPosition()); // returns { x: 0, y: 0 }
}
<p cdkDrag (cdkDragEnded)="onDragEnded($event)">
Draggable paragraph
</p>
Answered By - Leonid Blinov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.