如何在angular指令属性中使用特殊字符?

时间:2015-06-17 14:22:01

标签: javascript angularjs utf-8 special-characters directive

我想在自定义angularJS指令的属性中使用包含德语字符(Ä,Ö,Ü)的字符串。

例如:

<my-custom-directive my-label="Lärm" />

另一个例子是ui.bootstrap.tabs指令:

<tabset>
   <tab heading="Lärm"> content ... </tab>
   <tab heading="Second Heading"> content ... </tab>
</tabset>

这会产生标题为“L rm”的标签。有什么想法吗?

2 个答案:

答案 0 :(得分:3)

通常在一个好的编辑器中,您可以更改文档编码类型,保存文档。尝试将其设置为iso-8859-1 / utf-8并再次保存/上传。

接下来的赌注是用

更改html输出的编码
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
变音符号通常是试用版。错误...

答案 1 :(得分:2)

为javascript使用转义字符。

<table width="100%" cellspacing="0" cellpadding="4" border="1">
<tbody><tr>
  <th>Display</th>
    <th>Friendly Code</th>
    <th>Numerical Code</th>
    <th>Description</th>
</tr>
<tr class="grey">
	<td class="codes">Ä&nbsp;</td>
	<td class="codes">&amp;Auml;</td>
	<td class="codes">&amp;#196;</td>
	<td class="codes">Capital A-umlaut</td>
</tr>
<tr>
	<td class="codes">ä&nbsp;</td>
	<td class="codes">&amp;auml;</td>
	<td class="codes">&amp;#228;</td>
	<td class="codes">Lowercase a-umlaut</td>
</tr>
<tr class="grey">
	<td>É</td>
	<td>&amp;Eacute;</td>
	<td>&amp;#201;</td>
	<td>Capital E-acute</td>
</tr>
<tr>
	<td>é</td>
	<td>&amp;eacute;</td>
	<td>&amp;#233;</td>
	<td>Lowercase E-acute</td>
</tr>
<tr class="grey">
	<td class="codes">Ö&nbsp;</td>
	<td class="codes">&amp;Ouml;</td>
	<td class="codes">&amp;#214;</td>
	<td class="codes">Capital O-umlaut</td>
</tr>
<tr>
	<td class="codes">ö&nbsp;</td>
	<td class="codes">&amp;ouml;</td>
	<td class="codes">&amp;#246;</td>
	<td class="codes">Lowercase o-umlaut</td>
</tr>
<tr class="grey">
	<td class="codes">Ü&nbsp;</td>
	<td class="codes">&amp;Uuml;</td>
	<td class="codes">&amp;#220;</td>
	<td class="codes">Capital U-umlaut</td>
</tr>
<tr>
	<td class="codes">ü&nbsp;</td>
	<td class="codes">&amp;uuml;</td>
	<td class="codes">&amp;#252;</td>
	<td class="codes">Lowercase u-umlaut</td>
</tr>
<tr class="grey">
	<td class="codes">ß</td>
	<td class="codes">&amp;szlig;</td>
	<td class="codes">&amp;#223;</td>
	<td class="codes">SZ ligature</td>
</tr>
<tr>
	<td class="codes">«</td>
	<td class="codes">&amp;laquo;</td>
	<td class="codes">&amp;#171;</td>
	<td class="codes">Left angle quotes</td>
</tr>
<tr class="grey">
	<td class="codes">»</td>
	<td class="codes">&amp;raquo;</td>
	<td class="codes">&amp;#187;</td>
	<td class="codes">Right angle quotes</td>
</tr>
<tr>
	<td class="codes">„</td>
	<td class="codes">&nbsp;</td>
	<td class="codes">&amp;#132;</td>
	<td class="codes">Left lower quotes</td>
</tr>
<tr class="grey">
	<td class="codes">“</td>
	<td class="codes">&nbsp;</td>
	<td class="codes">&amp;#147;</td>
	<td class="codes">Left quotes</td>
</tr>
<tr>
	<td class="codes">”</td>
	<td class="codes">&nbsp;</td>
	<td class="codes">&amp;#148;</td>
	<td class="codes">Right quotes</td>
</tr>
<tr class="grey">
	<td class="codes">°</td>
	<td class="codes">&nbsp;</td>
	<td class="codes">&amp;#176;</td>
	<td class="codes">Degree sign (Grad)</td>
</tr>
<tr>
	<td class="codes">€</td>
	<td class="codes">&amp;euro;</td>
	<td class="codes">&amp;#128;</td>
	<td class="codes">Euro</td>
</tr>
<tr class="grey">
	<td>£</td>
	<td>&amp;pound;</td>
	<td>&amp;#163;</td>
	<td>Pound Sterling</td>
</tr>
</tbody></table>