我尝试在“title
“标记内使用“ng-bind-html
“指令来呈现带有货币符号的货币值,但表达式未求值。
这就是我的特灵:
$scope.salary= 10000;
$scope.currencySymbol = '€';//€
<div title="{{ng-bind-html= 'salary |currency:(currencySymbol+' '): 0'}}"> //This is not working
<span ng-bind-html="salary |currency:(currencySymbol+' '): 0"> </span> //working fine and renders €10000
当我在<span>
标记内显示时,它工作正常,但我也想在<title>
标记中显示相同的格式化值。
因此,想知道如何在“title
“标记中调用此“ng-bind-html
“,以显示与在<span>
标记中相同的输出?
2条答案
按热度按时间0md85ypi1#
ng-bind-html
is a directive。大括号用于表达式。将不会从表达式中处理指令。按如下所示重写表达式:
并将您的
currencySymbol
值替换为货币前缀所需的字符串。$scope.currencySymbol = "€ ";
Here is a working plunkr
Additional documentation on the currency filter
Related documentation on expressions
如果你真的专注于动态处理货币符号并将其视为html,你将需要编写一个接受sceHtmlString的自定义货币过滤器。Javascript字符串支持unicode,所以你提供的用例似乎不需要这样做。
qmb5sa222#
试试这个你可以添加标题到div。但它将是不可见的,因为标题不是一个文本字段。