Jak*_*kub 2 javascript css twitter-bootstrap angularjs
我有以下代码:
<a href="#" class="dropdown-toggle" data-toggle="dropdown" ng-bind="user.displayName">
<b class="caret"></b>
</a>
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我使用 Bootstrap 中的插入符类和 AngularJS 中的 ng-bind 。不幸的是,当我使用 mg-bind 时,插入符号在我的网页上不可见。但是,当我不使用 mg-bind 并仅内联该值时,如下所示:
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{user.displayName}}<b class="caret"></b>
</a>
Run Code Online (Sandbox Code Playgroud)
插入符号是可见的。
有什么想法如何在使用 ng-bind 时使插入符号可见吗?
来自文档: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>
Run Code Online (Sandbox Code Playgroud)
编辑:真的很好阅读与此主题半相关的文章:AngularJS : Why ng-bind is better than {{}} in Angular?
| 归档时间: |
|
| 查看次数: |
911 次 |
| 最近记录: |