Michal Bialek
Michal Bialek

Reputation: 499

Drag and drop in Angular 2

How to use this drag and drop library?

http://akserg.github.io/ng2-webpack-demo/#/dnd

Author did not provide any tutorial how to import it (and does not answer on my emails) to my project what is unacceptable. Plumker example contains variables which are not defined etc. Did you use this library?

Regards

Upvotes: 0

Views: 623

Answers (2)

Noor Ahmed
Noor Ahmed

Reputation: 1617

After installing the package in the project using:

npm install ng2-dnd --save

you have to include the package in your application module. The documentation (https://github.com/akserg/ng2-dnd) of the package explains that as :

import {BrowserModule} from "@angular/platform-browser";
import {NgModule} from '@angular/core';
import {DndModule} from 'ng2-dnd';

@NgModule({
    imports: [
        BrowserModule,
        DndModule.forRoot()
    ],
    bootstrap: [AppComponent]
})
export class AppModule {
}

After doing this step, the package is included in your application and you don't need to import it in each of your component (unless you need any instance of services provided by the package).

Here is how he is using the directive in the component.

 <div dnd-droppable class="panel panel-info" (onDropSuccess)="simpleDrop=$event">

Upvotes: 0

love prince
love prince

Reputation: 149

How to use Library is here: https://github.com/akserg/ng2-dnd
You can install

npm install ng2-dnd --save

Upvotes: 1

Related Questions