Is there a way to tell angular and angular-translate to handle strings which contains HTML content.
I have add_card-title = "To make ordering even quicker, <span class="nowrap">add a card now</span>"
as my Lang string. When i use it in my template by writing <p>{{'add_card-title' | translate}}</p>
I get string as it is.
Output: To make ordering even quicker, <span class="nowrap">add a card now</span>
expected output: To make ordering even quicker, add a card now
I know i can use ng-html-bind-unsafe
but it is not helping.
Not working:
<p ng-html-bind-unsafe="{{'add_card-title' | translate}}"></p>
Is there any way to achieve it?
Here is my plunker: http://plnkr.co/edit/nTmMFm9B94BmbTgo2h8H?p=preview
For reference you can see this issue: https://github.com/PascalPrecht/angular-translate/issues/173
note: i do not want to invlove controller to handle it.
You can do this out of box with angular-translate 2.0 these days.
<p translate="{{ 'PASSED_AS_INTERPOLATION' }}"></p>
works wonders for me.
You have to use the ng-bind-html directive without curly braces ({{ }})
To know the configuration needed in order to use that directive (ngBindHtml), follow this link: https://docs.angularjs.org/api/ng/directive/ngBindHtml
After ngSanitize is included, the following code should work:
<p ng-bind-html="'add_card-title' | translate"></p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With