gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 10:14:36 24 4
gpt4 key购买 nike

我有以下代码:

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com