生成的bootstrap navbar元素有问题。如果我在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">
<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>
但是如果我用'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>
并在控制器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;
......它不起作用。
我可以看到带有插入符号的Dropmenu按钮,但是如果我点击它就不会出现菜单。
我做错了吗?
提前致谢!
基督教