Uncaught TypeError: ctorParameters.map is not a fu

2019-07-11 19:24发布

问题:

I am trying ti use dragula in my angular2 app. Here is the app.module in my code:

    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 { }

unfortunatly, when i add the DragulaService to the providers, or DragulaModule to the imports i face with the following errors:

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)

I am sure, i have installed the dragula correctly.

回答1:

There is an opend issue : https://github.com/valor-software/ng2-dragula/issues/496

You may use Angular 2.1.1 and Dragula 1.2.0 with something like the following in your package.json :

"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",
...