1.0.0 • Published 5 years ago
lockes-sample-angular-drag-drop v1.0.0
AngularDragDrop
This project was generated with Angular CLI version 9.1.7.
it was created as a how to create a drag drop app
How to build me
- ng new angular-drag-drop
- cd angular-drag-drop/
- ng add @angular/material
- npm install @angular/cdk
- import CUSTOM_ELEMENTS_SCHEMA in app.module.ts
- add
schemas: [CUSTOM_ELEMENTS_SCHEMA]to @NgModule - set the following in the css {cdk-drag-preview,.cdk-drag-placeholder,.cdk-drag-animating}
- import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop' in app.component.ts
- create arrays in app.component.ts
- add onDropMethod()
- create two div with the cdkDropList markup, cdkDropListData='', cdkDropListConnectedTo="" and finaly (cdkDropListDropped)="onDrop($event)"
- inside each cdkDropList a div for each item in the array and a cdkDrag markup
- run
ng serve --open=true
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.
Code scaffolding
Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.
Build
Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.
Running unit tests
Run ng test to execute the unit tests via Karma.
Running end-to-end tests
Run ng e2e to execute the end-to-end tests via Protractor.
Further help
To get more help on the Angular CLI use ng help or go check out the Angular CLI README.
1.0.0
5 years ago