简体   繁体   English

输入时的角材质 CdkDragPreview

[英]Angular Material CdkDragPreview on Input

I have implemented CdkDrag for my Angular Material Table, Every mat-cell is an input (mat-form-field).我已经为我的 Angular Material Table 实现了 CdkDrag,每个 mat-cell 都是一个输入(mat-form-field)。

<mat-cell cdkDropList>

    <mat-form-field>
    <input
                  cdkDrag
                  cdkDragLockAxis="y"
                />
    </mat-form-field>

</mat-cell>

The point is to copy one cell to another cells.关键是将一个单元格复制到另一个单元格。 Functionality is working and done via cdkDropListEntered emitter.功能通过 cdkDropListEntered 发射器工作和完成。 However, i'm trying to use the properties CdkDragPreview and CdkDragPlacholder.但是,我正在尝试使用 CdkDragPreview 和 CdkDragPlacholder 属性。 These needs to be inside the cdkDrag, However since it's an input and there is no closing tag, I can't place the cdkDragPreview element (won't show).这些需要在 cdkDrag 中,但是由于它是一个输入并且没有结束标记,我无法放置 cdkDragPreview 元素(不会显示)。 Tried to place the cdkDrag property in the mat-form-field but then the drag and drop not working at all.试图将 cdkDrag 属性放在 mat-form-field 中,但拖放根本不起作用。

The overall point is to keep the dragged mat-cell visualwise in the same cell and not to show the dragging animation.总体要点是将拖动的 mat-cell 视觉上保持在同一个单元格中,而不是显示拖动动画。 Thanks.谢谢。

Try enclosing your <input> by another <div> .尝试用另一个<div>封闭你的<input> <div>

<mat-cell cdkDropList>
  <div cdkDrag cdkDragLockAxis="y">
    <mat-form-field>
      <input ...>
      <div *cdkDragPreview> ... </div>
    </mat-form-field>
  </div>
</mat-cell>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM