角翻译:占位符显示不正确的特殊字符 [英] Angular translate: placeholder not showing special characters correctly
问题描述
角转换为一个项目,它将会非常好。不过,我碰到一个问题,我不明白为什么它不工作。我有一个占位符文本,它已被翻译输入字段。这工作得很好,除了当翻译文本包含特殊字符,如øæåüöä等。
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.
这是我的code:
<input type="text" ng-model="search.query" autofocus translate-attr-placeholder="SEARCHPLACEHOLDER" translate />
<div translate>SEARCHPLACEHOLDER</div>
当设置为英语它输出:
<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>
正如你所看到的,棱角分明的翻译在&lt文本; DIV&GT;正确的,但它的输出逃脱输入元素的字符。
As you can see, angular translates the text in the <div> correctly, but it outputs escaped characters in the input-element.
søg
变为
søg
我找不到API的任何东西。我缺少什么?
I couldn't find anything in the API. What am I missing?
推荐答案
要显示特殊字符,使用 $ SCE
(严格的语境转义)
To display the special character, use $sce
(Strict Contextual Escaping)
下面是工作的jsfiddle
希望工程:)
这篇关于角翻译:占位符显示不正确的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!