Angular bootstrap navbar

636 views Asked by At

I have a problem with generated bootstrap navbar elements. If I create a navbar within html like below its working:

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">Brand</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul id="navContainer" class="nav navbar-nav">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        Dropmenu <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu" role="menu">
                        <li ng-class="navClass('Item_1')">
                            <a href='#/item1'>Item 1</a>
                        </li>
                        <li ng-class="navClass('Item_2')">
                            <a href='#/item2'>Item 2</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

But if I replace the dropdown element with an 'ng-bind-html':

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">Brand</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul id="navContainer" class="nav navbar-nav" ng-bind-html="content">

            </ul>
        </div>
    </div>
</nav>

and set the content within the controller js:

var text = "";

text += "<li class=\"dropdown\">";
text += "<a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Dropmenu <span class=\"caret\"></span></a>";
text += "<ul class=\"dropdown-menu\" role=\"menu\">";
text += "<li ng-class=\"navClass('Item_1')\"><a href='#/item1'>Item 1</a></li>";
text += "<li ng-class=\"navClass('Item_2')\"><a href='#/item2'>Item 2</a></li>";
text += "</ul>";
text += "</li>";

$scope.content = text;

... it's not working.

I can see the Dropmenu button with the caret, but if I click on it the menu doesn't appear.

Am I doing something wrong?

Thanks in Advance!

Christian

0

There are 0 answers