我正在尝试在我的angular2应用中使用dragula。 这是我的代码中的app.module:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { DragulaService, DragulaModule } from 'ng2-dragula/ng2-dragula';
import { AppComponent } from './app.component';
import { PlayComponent } from './play/play.component';
import {SelectedInstrumentsService} from './selected-instruments.service';
import {SizeService} from './size.service';
import {AudioFinderService} from './audio-finder.service';
@NgModule({
declarations: [
AppComponent,
PlayComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,DragulaModule
],
providers: [DragulaService,SelectedInstrumentsService,SizeService,AudioFinderService],
bootstrap: [AppComponent]
})
export class AppModule { }
不幸的是,当我将DragulaService
添加到providers
,或DragulaModule
添加到imports
我面临以下错误时:
Uncaught TypeError: ctorParameters.map is not a function
at ReflectionCapabilities.parameters (http://localhost:4200/main.bundle.js:39645:47)
at Reflector.parameters (http://localhost:4200/main.bundle.js:39856:48)
at CompileMetadataResolver.getDependenciesMetadata (http://localhost:4200/main.bundle.js:22231:156)
at CompileMetadataResolver.getTypeMetadata (http://localhost:4200/main.bundle.js:22196:26)
at CompileMetadataResolver.getDirectiveMetadata (http://localhost:4200/main.bundle.js:21969:28)
at http://localhost:4200/main.bundle.js:22038:49
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:4200/main.bundle.js:22031:44)
at http://localhost:4200/main.bundle.js:22019:50
at Array.forEach (native)
我确定,我已正确安装了dragula
。
答案 0 :(得分:5)
有一个opend问题:https://github.com/valor-software/ng2-dragula/issues/496
您可以在package.json中使用Angular 2.1.1和Dragula 1.2.0,如下所示:
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"ng2-dragula": "1.2.0",
...