I'm trying to create a Bootstrap navbar with dropdowns from a two-level array. However, the dropdowns will only work when the dropdown class on <li> and the dropdown-toggle class on <li> are hard-coded.
Since some of my menu items should have a dropdown, and some should not, I want to set these using ng-class. Is there any way to delay ui-bootstrap untill the html has been compiled?
I found somewhere that jQuery('.dropdown-toggle').dropdown(); might reinitialize the dropdown, but the dropdown() function is not recognized in my case.
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li ng-repeat="navItem in structure.navItems" ng-class="{'active': structure.isActive(navItem), 'dropdown': navItem.subItems}"> <a href="{{navItem.href}}" ng-class="{'dropdown-toggle': navItem.subItems}" data-toggle="dropdown">
{{navItem.name}}
<span class="caret" ng-if="navItem.subItems"></span>
</a>
<!-- start dropdown menu -->
<ul class="dropdown-menu">
<li ng-repeat="subItem in navItem.subItems"> <a href="{{subItem.href}}" ng-class="{'active': structure.isActive(subItem)}">
{{subItem.name}}
</a>
</li>
<!-- dit kan ook nog: <li class="divider"></li>
<li class="dropdown-header">Nav header</li>
-->
</ul>
<!-- end dropdown menu -->
</li>
</ul>
</div>