我在数据库中保存了HTML代码。当我调用它并使用[innerHtml]在Home.html
上显示它时,我希望它显示带有其HTML属性的文本,但未显示。
我的下面home.html
中的代码:
<ion-item *ngFor="let list of search_qa;let i =index;">{{list.q_subject}}<br/><br/>
<span (click)="open(list.qid)" [innerHtml]="list.q_describe">{{list.q_describe}}</span>
来自数据库的代码:
<td width="498" colspan="2" valign="top" style="width:373.25pt;border:solid black 1.0pt;
border-left:none;background:transparent;padding:4.0pt 4.0pt 4.0pt 4.0pt;
height:30.35pt">
<p class="MsoNoSpacing" style="text-align:justify;text-indent:.3pt"><b><span lang="EN-GB" style='font-size:16.0pt;font-family:"Chaparral Pro",serif'>A
particle moves with simple harmonic motion in a straight line. In first </span></b><b><span lang="EN-GB" style="font-size:16.0pt;font-family:Symbol">t </span></b><b><span lang="EN-GB" style='font-size:16.0pt;font-family:"Chaparral Pro",serif'>s,
after starting from rest it travels a <font color="red">distance a</font>, and in next </span></b><b><span lang="EN-GB" style="font-size:16.0pt;font-family:Symbol">t</span></b><b><span lang="EN-GB" style='font-size:16.0pt;font-family:"Chaparral Pro",serif'> s it
travels 2a, in same direction, then </span></b></p>
</td>
[请注意:当我对其进行硬编码时,它会按预期方式显示,但是当它来自数据库时,它的格式不正确,如下所示是我的表单的屏幕截图:
您应该清理HTML以便正常工作,最好的方法是使用管道。 here是一个很棒的教程。