0

I'm using Angular 2.0.0-rc6 and ng2-dragula. I wanted to create a simple list of words and be able to drag n' drop inside it.

When i try to add the attribute "directive" to my component, it says that "directive" can not be a part of the Component Metadatatype and i'm not allowed to bind the directive to my component. I found several tutorials that implements the attribute "directive" inside the component declaration.

How can I bind the Dragula directive to my component ?

import { Component } from '@angular/core';

import {Dragula, DragulaService} from 'ng2-dragula/ng2-dragula';

@Component({
  selector: 'my-app',
  // directives: [Dragula],
  // viewProviders: [DragulaService],
  templateUrl: "app/templates/app.component.html"
})
NoP
  • 15
  • 6

1 Answers1

0

You should declare it within NgModule like:

...
import {Dragula, DragulaService} from 'ng2-dragula/ng2-dragula';

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ App, Dragula ],
  providers: [ DragulaService ],
  bootstrap: [ App ]
})
export class AppModule {}

Plunker Example

yurzui
  • 205,937
  • 32
  • 433
  • 399
  • It works for me thank you. Stefan, there's only my import in app.module.ts that is different than your code: import {Dragula, DragulaService} from 'ng2-dragula/ng2-dragula'; – NoP Sep 07 '16 at 08:51