我是 Ionic/Angular 新手。 我需要打印一个包含一些 HTML 的数组
{
"code" : "06",
"descr" : "Some text:</br>Other text.<br/>Other text</br>Other text."
}
但它不会转到新行,它甚至会打印我页面中的标签。 有办法避免这种情况吗?
我读过一些有关 ng-bind-html-unsafe 的内容,但显然已从 Angular 中删除。
最佳答案
尝试使用innerHtml
:
<ng-container *ngFor="let item of yourArray">
<div [innerHTML]="item.descr"></div>
</ng-container>
关于html - Ionic,数组中的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59058056/