Angular Material: 删除 cdk 组件外的项目 onDrop
Angular Material: Remove item onDrop outside cdk component
我目前正在使用 angular material CDK DragAnDrop 来实现某些列表功能。
我想要完成的是:
我将列表 A 中的一个元素拖放到列表 B 中。
如果我将元素从列表 B 拖放到列表 B 之外(也在列表 A 之外),我想从列表 B 中删除该元素。
是否有一些指令或 api 可以用来验证我是否在 cdkDropList 组件之外放置了一个元素?
Is there some directive or api that I can use to validate that I'm dropping an element outside cdkDropList component?
您可以使用 CdkDragDrop 事件的 isPointerOverContainer
属性。
如果物品掉落到容器外,它将被设置为 false,否则为 true。
我目前正在使用 angular material CDK DragAnDrop 来实现某些列表功能。
我想要完成的是:
我将列表 A 中的一个元素拖放到列表 B 中。 如果我将元素从列表 B 拖放到列表 B 之外(也在列表 A 之外),我想从列表 B 中删除该元素。
是否有一些指令或 api 可以用来验证我是否在 cdkDropList 组件之外放置了一个元素?
Is there some directive or api that I can use to validate that I'm dropping an element outside cdkDropList component?
您可以使用 CdkDragDrop 事件的 isPointerOverContainer
属性。
如果物品掉落到容器外,它将被设置为 false,否则为 true。