Core: HTML classes support

Created on 29 Aug 2016  路  2Comments  路  Source: ngx-translate/core

I'm submitting a ... (check one with "x")

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[x] feature request

Current behavior

When I hade some HTML tags the tags are added in she string. For example if my translation string is "This is <b>bold</b>" the output in my HTML page would be exactly the same and not "this is bold".

Expected/desired behavior

I wondered if it was possible to add some HTML classes support. For example by adding a param in the translation function.

Thanks,

questiosupport

All 2 comments

You can already do that with innerHTML:

<div [innerHTML]="{{ 'SOME_KEY' | translate }}"></div>

with:

{
  "SOME_KEY": "This is <b>bold</b>"
}

Thanks a lot and sorry !

Edit: A little precision. When using innerHTML you must not put the curly brackets :

<div [innerHTML]=" 'SOME_KEY' | translate "></div>
Was this page helpful?
0 / 5 - 0 ratings