无法使用DropdownModule和ng2-bootstrap

时间:2016-10-25 14:30:49

标签: angular ng2-bootstrap

当尝试将DropdownModule和ButtonsModule与最新(1.1.14)版本的ng2-bootstrap一起使用时,我收到以下错误

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

我一直在使用DROPDOWN_DIRECTIVES和BUTTON_DIRECTIVES以及1.0.24版本的ng2-bootstrap。在尝试转换时,我甚至无法在我的NgModule中声明它而没有错误

这是我的模块

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

1 个答案:

答案 0 :(得分:3)

模块应该放在@NgModule.imports而不是declarations

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