【问题标题】:Bootstrap caret class does not work with ng-bind引导插入符号类不适用于 ng-bind
【发布时间】:2014-07-04 00:51:43
【问题描述】:

我有以下代码:

<a href="#" class="dropdown-toggle" data-toggle="dropdown" ng-bind="user.displayName">
    <b class="caret"></b>
</a>

如您所见,我使用 Bootstrap 中的 caret 类和 AngularJS 中的 ng-bind。不幸的是,当我使用 mg-bind 时,我的网页上看不到插入符号。但是,当我不使用 mg-bind 而只是像这样内联值时:

<a href="#" class="dropdown-toggle" data-toggle="dropdown">
    {{user.displayName}}<b class="caret"></b>
</a>

插入符号可见。

任何想法如何在使用 ng-bind 时使插入符号可见?

【问题讨论】:

  • 您是否尝试过使用其他 HTML 元素而不是 &lt;b&gt;

标签: javascript css angularjs twitter-bootstrap


【解决方案1】:

来自文档:https://docs.angularjs.org/api/ng/directive/ngBind

ngBind 属性告诉 Angular替换 具有给定表达式的值的指定 HTML 元素

因此,使用 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?

【讨论】:

    猜你喜欢
    • 2014-02-06
    • 2014-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多