简体   繁体   English

通过从数组中拖放 angular 来组织和重新排序文件

[英]Organize and re-order files by drag and drop angular from array

I work on feature and the feature need to give the user the ability to re order the file before generate it to the server.我致力于功能,该功能需要让用户能够在将文件生成到服务器之前重新排序文件。 I use ng bootstrap for creating the modal and get as inputs array of files then I show the files in the modal.我使用 ng bootstrap 创建模态并获取作为输入文件数组,然后在模态中显示文件。 How can the user replace the order of the files on the modal?用户如何替换模态上文件的顺序? I need a package that let you re order the file from the UI.我需要一个可以让您从 UI 重新订购文件的包。

在此处输入图片说明

I would heartily recommend using "@angular/cdk" package, which is maintained by Angular team itself, meaning it will most probably always be updated with upcoming angular releases, decently tested, well documented and you should get proper support from devs.我衷心推荐使用“@angular/cdk”包,它由 Angular 团队自己维护,这意味着它很可能总是随着即将发布的 Angular 版本进行更新,经过适当测试,有据可查,并且您应该得到开发人员的适当支持。

I've used it's drag and drop features in multiple projects so far and never had any problems, though as always - your mileage may vary.到目前为止,我已经在多个项目中使用了它的拖放功能,但从未遇到任何问题,尽管与往常一样 - 您的里程可能会有所不同。

The package's API (including drag and drop) is documented on the material components site: https://material.angular.io/cdk包的 API(包括拖放)记录在材料组件站点上: https : //material.angular.io/cdk

Basic example of reordering lists using drag and drop: https://material.angular.io/cdk/drag-drop/overview#reordering-lists使用拖放重新排序列表的基本示例: https : //material.angular.io/cdk/drag-drop/overview#reordering-lists

Note that while the docs are hosted as part of material docs, you don't need the material dependency itself, only the CDK package.请注意,虽然文档作为材料文档的一部分托管,但您不需要材料依赖本身,只需要 CDK 包。

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

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