【发布时间】:2018-02-18 10:17:12
【问题描述】:
我想在我的html代码中动态放置一段html代码,所以我写了如下代码:
<ng-container [innerHTML]="buttonIcon"></ng-container>
Angular 说 innerHTML 不是 ng-container 的有效属性
我不想使用如下第三个 html 标签:
<div [innerHTML]="buttonIcon"></div>
那么如何在没有任何标签内部 html 绑定的情况下插入 html 代码呢?
【问题讨论】:
-
<ng-template ...呢? -
我测试过,还是一样的错误
-
没有任何视觉效果,接受innerHTML
-
在 div 上使用 [outerHTML] 会被替换
-
@MichaelWestcott
ERROR DOMException: Failed to set the 'outerHTML' property on 'Element': This element has no parent node