我有以下代码:
<a href="#" class="dropdown-toggle" data-toggle="dropdown" ng-bind="user.displayName">
<b class="caret"></b>
</a>
正如你所看到的,我使用 Bootstrap 中的插入符类和 AngularJS 中的 ng-bind 。不幸的是,当我使用 mg-bind 时,插入符号在我的网页上不可见。但是,当我不使用 mg-bind 而只是内联值时,如下所示:
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{user.displayName}}<b class="caret"></b>
</a>
插入符号可见。
有什么想法如何在使用 ng-bind 时使插入符号可见吗?
最佳答案
来自文档:https://docs.angularjs.org/api/ng/directive/ngBind
The ngBind attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression
因此,使用 ng-bind
替换元素的内容(包括插入符号)。
你可以这样做:
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span ng-bind="user.displayName"></span><b class="caret"></b>
</a>
编辑:非常好的阅读与此主题半相关的内容:AngularJS : Why ng-bind is better than {{}} in angular?
关于javascript - Bootstrap 插入符类不适用于 ng-bind,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24559105/