ngx-bootstrap dropdown not opening angular 4 bootstrap 4

jb44 picture jb44 · Aug 17, 2017 · Viewed 8.2k times · Source

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

Answer

Matthias Schaffer picture Matthias Schaffer · Aug 17, 2017

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