Angular translate innerHTML with params
Asked Answered
I

1

21

I would like to translate a source text containing <a> tag with url param, the string text example:

STRING_TEXT = 'some text <a href={{url}}>some link name</a>'

I know there it is possible to translate

<div [innerHTML]="'STRING_TEXT' | translate"></div>

as described in docs.

but how I could include url param in this situation?

Ihab answered 21/9, 2018 at 9:30 Comment(0)
T
33

translate pipe takes parameter object which is context for the translation message, you can pass this param as:

<div [innerHTML]="'STRING_TEXT' | translate: {url: someVariableOnComponent}"></div>

See the docs

Tolmann answered 21/9, 2018 at 9:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.