在我的 Angular 4 应用程序中,来自 ng-bootstrap 的 ngbDropdown-Element 不起作用。
我为此案例安装了以下 npm 模块:
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.22",
"bootstrap": "4.0.0-alpha.6",
"bootstrap-sass": "^3.3.7",
我的 app.module.ts 看起来像这样:
import { BrowserModule } from "@angular/platform-browser"
import { NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
import { AppComponent } from "./app.component";
import { FileitHeaderComponent } from "./fileit-header/fileit-header.component";
import {TranslateModule} from "ng2-translate";
import { CCACampaignComponent } from "./cca-campaign/cca-campaign.component";
import {NgbModule} from "@ng-bootstrap/ng-bootstrap";
@NgModule({
declarations: [
AppComponent,
FileitHeaderComponent,
CCACampaignComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
TranslateModule.forRoot(),
NgbModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
在 CCA 活动中,我尝试使用 ng-bootstrap 的演示:
<div ngbDropdown class="d-inline-block">
<button class="btn btn-outline-primary" id="dropdownMenu1" ngbDropdownToggle>Toggle dropdown</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu1">
<button class="dropdown-item">Action - 1</button>
<button class="dropdown-item">Another Action</button>
<button class="dropdown-item">Something else is here</button>
</div>
</div>
但不幸的是,这段代码的结果非常糟糕:
当我点击它时没有任何反应......