2

I have the following piece of code:

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

As you can see I use caret class from Bootstrap and ng-bind from AngularJS. Unfortunately when I use mg-bind the caret is not visible on my webpage. However, when I don't use mg-bind and just inline the value like this:

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

the caret is visible.

Any ideas how to make the caret visible while using ng-bind?

Jakub
  • 3,129
  • 8
  • 44
  • 63

1 Answers1

5

From the docs: 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

So, using ng-bind replaces the content of the element (including your caret).

You could do something like this:

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

Edit: really good read semi-related to this topic: AngularJS : Why ng-bind is better than {{}} in angular?

Community
  • 1
  • 1
Steve Sanders
  • 8,444
  • 2
  • 30
  • 32