Ngx-bootstrap: Nav Dropdown and responsive menu not working

Created on 7 Sep 2016  路  3Comments  路  Source: valor-software/ngx-bootstrap

I am trying to create a bootstrap nav with a dropdown as below:

<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">BRAND</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="#">Home</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li role="separator" class="divider"></li>
                        <li class="dropdown-header">Nav header</li>
                        <li><a href="#">Separated link</a></li>
                        <li><a href="#">One more separated link</a></li>
                    </ul>
                </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Logout</a></li>
            </ul>
        </div><!--/.nav-collapse -->
    </div>
</nav>

The above code works fine in a standalone html page, but when running with angular and ng2-bootstrap, the dropdown does not work and the collapsed responsive menu does not open the dropdown either.

I am a little confused regarding the proper steps to integrate ng2-bootstrap. I have the following:

  • add <script src=".../ng2-bootstrap.min.js"></script>in index.html
  • add <link href=".../bootstrap.min.css" rel="stylesheet"> in index.html
  • Add Ng2BootstrapModule as imported module in app.module.ts

Do I need to also include references to bootstrap.js and jquery.js as I need to with a standalone html page? I have tried, but it does not change the situation.

Most helpful comment

This is a pretty substantial limitation. I would think that adding support for navbar and the collapsed responsive navbar should be very high on the priority list.

All 3 comments

This is a known feature request: #540 and #188

This is a pretty substantial limitation. I would think that adding support for navbar and the collapsed responsive navbar should be very high on the priority list.

Did this ever get implemented?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

haisaco picture haisaco  路  3Comments

ctrl-brk picture ctrl-brk  路  3Comments

ravirajhalli picture ravirajhalli  路  3Comments

MihaiHoriaPopescu picture MihaiHoriaPopescu  路  3Comments

hugonne picture hugonne  路  3Comments