项目作者: notadd

项目描述 :
基于@swimlane/ngx-dnd,可拖拽,可配置actions的Angular树组件
高级语言: TypeScript
项目地址: git://github.com/notadd/ngx-tree-dnd.git
创建时间: 2018-07-27T02:05:37Z
项目社区:https://github.com/notadd/ngx-tree-dnd

开源协议:

下载


NgxTreeDnd

基于@swimlane/ngx-dnd,可拖拽,可配置actions的Angular树组件
保留原有的api和feature,修改了默认样式,添加了折叠、action配置

How to use

step-1

安装@notadd/ngx-tree-dnd

安装依赖

  • npm install @swimlane/dragula material-design-icons

step-2

  • 添加NgxTreeDnDModule到你的AppModule
  • 引入material-design-icons

    如果你的项目是Angular6,需要在polyfills.ts中添加如下代码:
    (window as any).global = window;

step-3

  • 在你的component中添加ngx-tree-dnd-container组件
    1. <ngx-tree-dnd-container
    2. [model]="nestedLists"
    3. [actions]="actions">
    4. </ngx-tree-dnd-container>
  1. nestedLists = [
  2. {
  3. label: 'Item 1',
  4. children: []
  5. },
  6. {
  7. label: 'Item 2',
  8. children: [
  9. {
  10. label: 'Item 2a',
  11. children: []
  12. },
  13. {
  14. label: 'Item 2b',
  15. children: []
  16. },
  17. {
  18. label: 'Item 2c',
  19. children: []
  20. }
  21. ]
  22. },
  23. {
  24. label: 'Item 3',
  25. children: [
  26. {
  27. label: 'Item 3a',
  28. children: []
  29. },
  30. {
  31. label: 'Item 3b',
  32. children: []
  33. },
  34. {
  35. label: 'Item 3c',
  36. children: []
  37. }
  38. ]
  39. }
  40. ];
  1. actions = [
  2. {
  3. // action按钮material icon
  4. icon: 'remove_red_eye',
  5. /* 点击action按钮的回调函数 */
  6. callback: (model) => {
  7. /* model为当前actions所在item的model */
  8. /* do something */
  9. }
  10. },
  11. {
  12. icon: 'edit',
  13. callback: (model) => {}
  14. },
  15. {
  16. icon: 'delete',
  17. callback: (model) => {}
  18. }
  19. ];

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.