gpt4 book ai didi

angularjs - ng-bootstrap ngbDropdown 在 Angular 4 中不起作用

转载 作者:太空狗 更新时间:2023-10-29 17:46:28 25 4
gpt4 key购买 nike

在我的 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>

但是不幸的是这段代码的结果很糟糕:

enter image description here

当我点击它时没有任何反应......

最佳答案

@菲利普只需对您的 HTML 代码稍作更改即可:

<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" ngbDropdownMenu>
<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>

ngbDropdownMenu is property added to "dropdown-menu" div.

关于angularjs - ng-bootstrap ngbDropdown 在 Angular 4 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43111633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com