GR Envoy GR Envoy - 1 month ago 39
AngularJS Question

Unable to use DropdownModule with ng2-bootstrap

When trying to use both DropdownModule and ButtonsModule with the most current (1.1.14) version of ng2-bootstrap I get the following error

Uncaught Error: Unexpected module 'DropdownModule' declared by the module


I had been using DROPDOWN_DIRECTIVES and BUTTON_DIRECTIVES with a 1.0.24 version of ng2-bootstrap. When trying to convert I can't even declare it in my NgModule without the error

Here is my module

import { DeviceService } from "./services/device.service";
import { DlSimpleFilterComponent } from "./dl-simple-filter/dl-simple-filter.component";
import { HttpModule } from "@angular/http";
import { TimepickerComponent} from "ng2-bootstrap";

//BDS Removed to get running
//import { DropdownModule, ButtonsModule } from 'ng2-bootstrap/ng2-bootstrap';
//import { DropdownModule } from 'ng2-bootstrap/ng2-bootstrap';
import { DropdownModule } from 'ng2-bootstrap/components/dropdown';


@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule
],
declarations: [
AppComponent,
OperatorPipe,
ConversationPipe,
DlSimpleFilterComponent,
DropdownModule,
// ButtonsModule,
TimepickerComponent
],
providers: [
OperatorService,
ConversationService,
DeviceService,
DlSimpleFilterComponent
],
bootstrap: [
AppComponent
]
})
export class AppModule { }

Answer

Modules should go in the @NgModule.imports not the declarations.

imports:      [
    BrowserModule,
    FormsModule,
    HttpModule,
    DropdownModule,
],