How can i make a MatDialog draggable / Angular Material

Viewed 29995

Is it possible to make a Angular Material Dialog draggable? I installed angular2-draggable and can of course use the functionality on all other elements.

But because the dialogs are dynamically created i can not use ngDraggable on a special element or can use a template variable.

4 Answers

in your module, import the cdk drag

import { DragDropModule } from '@angular/cdk/drag-drop';

and in html where dialog is for example, just add to any html element. i have added to first element and then i can drag the dialog anywhere i pick.

<mat-dialog-content cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle>
  content...
</mat-dialog-content>
Related