angular.js - 包装在跨度货币符号和小数 [英] angular.js - wrapping the currency symbol and decimal numbers in spans
问题描述
你都不可能做这样的事情的角度?
Can you possibly do something like this in angular?
这不是很可能做到这一点,因为不分析标记或东西。
It's not quite possible to do this, as doesn't parse tags or something
{{10000 |货币:<跨度> $< / SPAN>中}}
<一个href=\"http://plnkr.co/edit/WluYoe2Ltmhmhvr8BBWX?p=$p$pview\">http://plnkr.co/edit/WluYoe2Ltmhmhvr8BBWX?p=$p$pview
更何况不知何故单独的十进制数。
let alone somehow separate decimal number..
理想的结果将是
1 000 000&LT;跨度类=DEC&GT; 00&LT; / SPAN&GT;&LT;跨度类=恶狗&GT;€&LT; / SPAN&GT;
这不是真的有可能与任何过滤器设置做的是它..?
It's not really possible to do with any filter settings is it..?
我可以尝试和修改角的货币滤波器和 formatNumber
的功能,但它仍然把它作为一个文本,而不是一个span元素。
I could try and modify angular's currency filter and the formatNumber
function, but it still would take it as a text rather than a span element.
//编辑
你能真正做到这一点<一个href=\"http://plnkr.co/edit/dcEhHi8sp43564ZvC4D1?p=$p$pview\">http://plnkr.co/edit/dcEhHi8sp43564ZvC4D1?p=$p$pview
&LT; p NG绑定HTML的不安全=10000 |货币:'&LT;跨度&GT; $&LT; / SPAN&GT;'&GT;&LT; / P&GT;
仍茫然不知小数虽然
推荐答案
它实际上可能做到这一点。
It's actually possible to do this
&LT; p NG绑定HTML的不安全=10000 |货币:'&LT;跨度&GT; $&LT; / SPAN&GT;'&GT;&LT; / P&GT;
或将其套在这样的本国货币过滤器
or wrap it around the native currency filter like this
app.filter('currencys', ['$filter', '$locale',
function($filter, $locale) {
return function (num) {
var sym = $locale.NUMBER_FORMATS.CURRENCY_SYM;
return $filter('currency')(num, '<span>'+ sym +'</span>');
};
}
]);
,然后使用它像这样
and then use it like this
&LT;跨度NG绑定HTML的不安全=10000 | currencys&GT;&LT; / SPAN&GT;
这篇关于angular.js - 包装在跨度货币符号和小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!