【发布时间】:2017-04-12 20:21:18
【问题描述】:
我从后端获取了一个编码 html,但我无法对其进行解码。
我尝试使用 decodeURIComponent 和 decodeURI。
I got from server='
"<table style="background-color: white;">
<tbody>
<tr>
<td>
<div id="voucher">
<table>
<tr>
<td colspan="1" class="normal-left">ID:</td>
<td colspan="3" class="normal-left">ce203c7c804c4f258947adf3d63b2d7d</td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</tbody>
</table>"
'
// This is my HTML
<ion-content padding>
<ion-list>
<ion-item>
<span [innerHtml]="aux"></span>
</ion-item>
</ion-list>
</ion-content>
我曾经在 Jquery 中使用 document.getElementById("aux").innerHTML = $('').html(voucher).text(); 进行解码
但我不知道 Angular 2 是否有类似的东西。
谢谢
【问题讨论】:
-
假设这是您要插入 DOM 的 HTML,您应该告诉服务器人员不要将
&lt;转义为&lt;等。然后您可以使用innerHTML插入它。 -
innerHTML 现在是 innerHtml。