Reputation: 10453
I'm working on localization with Angular and I'm stuck with one last thing here.
I have this json blob
{
"key": "_need_to_login_",
"value": "You need to <a ng-click=\"login()\">log in</a> to add an event.",
"description": "Banner alert info tell user to login before they can add an event"
}
So with this Angular i18n module I will be able to do this
{{ "_need_to_login_" | i18n }}
The problem is that it contains some markup in there and it will simple escape it and will display this on the page
You need to <a ng-click="login()">log in</a> to add an event.
But with ngSanitize I'm able to unescape that markup and display it correctly as:
You need to log in to add an event.
But I don't have that ng-click
inserted as well.
Try copy that and test it here : http://docs.angularjs.org/api/ngSanitize/service/$sanitize
My question is that how can I insert ng-click
from the injected code as well as unescape the string?
Upvotes: 2
Views: 1626
Reputation: 1335
ng-bind-html should do what you want. Let me know how it works out, we are planning to add translation support soon to our app.
http://docs.angularjs.org/api/ng/directive/ngBindHtml
Edit2: nevermind about the jsfiddle edit. It didnt work.
Upvotes: 1