Angular attribute expression

I have a page using angular where im implements a popover from bootstrap:

<img class="state-msg" data-toggle="popover" ng-popover data-content="{{item.status.message}}" data-trigger="hover" data-placement="top" ng-src="{{item.status.stateIcon}}"/> 

Data content is not displayed correctly. It returns literally {{item.status.message}} instead of the message value.

Does angular problem expression w in 'data-' attributes?

Tpx

+4
source share
2 answers

Remove this interpolation notation. With {{, }} , AngularJS performs string interpolation rather than model binding.

 data-content="item.status.message" 
+3
source

You can try:

 ng-attr-src="{{item.status.stateIcon}}" 

From the documentation:

"If the attribute with the binding is the prefix prefix ngAttr (denormalized prefix: 'ng-attr-', 'ng: attr-'), then during compilation the prefix will be removed and the binding will be applied to the unprefixed attribute. This allows you to bind attributes that otherwise the case would be handled by browsers in their uncompressed form (for example, the img [src] or svg circle [cx] attributes). "

+9
source

Source: https://habr.com/ru/post/1499366/


All Articles