[英]HTML not interpreting tags
I am saving data into mysql using htmlspecialchars() .我正在使用htmlspecialchars()将数据保存到 mysql 中。 On output when getting data using htmlspecialchars_decode() before displaying it in Angular .
在 output 上使用htmlspecialchars_decode()在Angular中显示数据之前获取数据。 But instead of interpreting the html code it is displaying it as a text.
但不是解释 html 代码,而是将其显示为文本。
Data in Database数据库中的数据
<p class="fr-tag"><span>test</span></p>
Code being displayed after htmlspecialchars_decode() htmlspecialchars_decode() 之后显示的代码
<p class="fr-tag"><span>test</span></p>
Displaying the output from database into div as follows将数据库中的 output 显示到 div 中,如下所示
<div *ngIf="product.pdescription" class="mt-2 product-description">{{product.pdescription}}</div>
I have also tried using html_entity_decode but didn't help.我也尝试过使用html_entity_decode但没有帮助。
Following is a screenshot of the browser以下是浏览器截图
In order to make it working you should use innerHTML or outerHTML binding:为了使其正常工作,您应该使用innerHTML或 outerHTML 绑定:
<div *ngIf="product.pdescription" ... [innerHTML]="product.pdescription"></div>
But beware about some limitations但要注意一些限制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.