ngPluralize: support for HTML tags in translations?
I found myself in a situation where some of the translation, and not all, must be within a strong tag. Since the ngPluralize directive uses element.text() (source) then the string is HTML escaped, and it doesn't work.
<ng:pluralize count="users.length" when="{other:'<strong>{}</strong> users'}" />
Since it may lead to XSS issues, I was wondering how to allow ngPluralize to use element.html() in some cases. If $interpolate already escapes the interpolated values, then maybe the directive could use element.html()? Or may be add an attribute like as="html" to give the user control over the HTML safeness of the translation? All it would need then is:
function ngPluralizeWatchAction(newVal) {
if (attr.as === 'html') {
element.html(newVal);
} else {
element.text(newVal);
}
}
+1
+1
+1
+1
+1
+1
+1
+1
+1
:+1:
+1
+1
+1
+1
+1. In the mean time I've created a gist that I'm using in place of ngPluralize where I need HTML
+1
:+1:
+1
+1
Using html with pluralize should be strait-forward with a small ad-hoc directive as it is the case here http://plnkr.co/edit/mkKt5rqYorGu4a1t93J8?p=preview