(UPDATE: Issue Resolved - I discovered that I needed to include the JavaScript within $(document).ready(function()), which was previously missing. The example below worked perfectly for me.)
I am attempting to implement a Multi-Level Navbar with Angular 6 & Bootstrap 4.
How can I expand and collapse sub-menus on click or hover? My goal is for the menu to expand towards the right...
For instance, I came across a solution on this webpage - but I'm unsure about how to integrate Javascript into an Angular component. https://codepen.io/surjithctly/pen/PJqKzQ
Here are details of my version:
Below is my Navbar Code:
<nav class="navbar navbar-expand-lg navbar-dark">
<a class="navbar-brand" href="#" style="color: red;">
My NAVBAR
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownHI" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Menu
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownHI">
<li><a class="dropdown-item" href="#">Action</a></li>
<li class="nav-item dropdown"><a class="dropdown-item dropdown-toggle" href="#">Submenu</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Submenu action</a></li>
<li><a class="dropdown-item" href="#">Another submenu action</a></li>
</ul>
</li>
<li class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">View All</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>