问题
I am currently using angular-translate for a project, and it's going really well. However I run into a problem and I can't see why it's not working. I have an input field with a placeholder text, which has to be translated. This works fine, except when the translation-text includes special characters such as øæåüöä and so on.
This is my code:
<input type="text" ng-model="search.query" autofocus translate-attr-placeholder="SEARCHPLACEHOLDER" translate />
<div translate>SEARCHPLACEHOLDER</div>
when set to english it outputs:
<input placeholder="Search for magazines" (rest omitted)>
<div class="ng-scope" translate="">Search for magazines</div>
however when i set it to danish it outputs:
<input placeholder="Søg i indholdet af magasiner..." (rest omitted)>
<div class="ng-scope" translate="">Søg i indholdet af magasiner...</div>
As you can see, angular translates the text in the <div> correctly, but it outputs escaped characters in the input-element.
søg
becomes
søg
I couldn't find anything in the API. What am I missing?
回答1:
To display the special character, use $sce
(Strict Contextual Escaping)
Here is the working JSFIDDLE
Hope it works :)
来源:https://stackoverflow.com/questions/32442680/angular-translate-placeholder-not-showing-special-characters-correctly