5

I can't figure out what's going on here - I've included ngx-dropdown code that I believe is correct based on documentation:

home.component.html

    <div class="btn-group" dropdown>
      <button dropdownToggle type="button" class="btn btn-primary dropdown-toggle">
        Button dropdown <span class="caret"></span>
      </button>
      <ul *dropdownMenu class="dropdown-menu" role="menu">
        <li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
        <li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
        <li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
        <li class="divider dropdown-divider"></li>
        <li role="menuitem"><a class="dropdown-item" href="#">Separated link</a>
        </li>
      </ul>
    </div>

app.module.ts

@NgModule({
  imports: [
    BsDropdownModule.forRoot(),
    ...
    ]

site.module.ts (this is the module that contains the home component)

@NgModule({
  imports: [
    BsDropdownModule,

I'm using angular-cli and I've included the bootstrap style:

    "../node_modules/bootstrap/dist/css/bootstrap.min.css",

and in index.html I've added a snippet to let the browser know I'm using bootstrap 4:

<script>window.__theme = 'bs4';</script>
<app-root>Loading . . .</app-root>

The button appears, and there are no errors shown in the console. I can see the dom changing when I click the button ("open" and "show" are being added to the styles). But nothing below the button opens up - no menu is shown.

I don't know where else to look

2
  • Can you create plunkr? Commented Aug 17, 2017 at 5:30
  • why dont you use directives to add and remove classes for bootstrap drop down instead of using a extension . example link . check the nav bar Commented Aug 17, 2017 at 6:23

2 Answers 2

5

I have this problem too. After some wasted hours i found this:

It's an official issue:

https://github.com/valor-software/ngx-bootstrap/issues/2413

Sign up to request clarification or add additional context in comments.

Comments

2

I had the same problem. After I import BrowserAnimationsModule from '@angular/platform-browser/animations';' to app.module.ts and add BrowserAnimationsModule to imports: [] the problem is resolved. With some unnecessary codes, you app.module.ts should look like below. I'm currently using Angular 9.0:

import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
...
@NgModule({
 ...
},
 imports:[
  BrowserAnimationsModule,
  BsDropdownModule.forRoot()
 ],
 ....
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.