javascript - Bootstrap 插入符类不适用于 ng-bind

标签 javascript css angularjs twitter-bootstrap

我有以下代码:

<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/

相关文章:

javascript - 如何降低此 jquery 计数器动画的速度

angularjs - ionic - 在同一页面中的多个 View

javascript - ng-repeat 中的 Angular 切换过滤器

javascript - 如何从angularjs访问变量express

javascript - bxslider javascript slider 不工作

Javascript 通知 - 最大图标大小

css - 使用 Sass 更改类

html - 为什么 -webkit-margin-before (以及之后、开始、结束)没有被我的显式边距和填充规则覆盖?

css - Vue.js : How to modify color of selected-variant in table of BootstrapVue?

javascript - 在 Protractor 测试中获取和使用属性