【发布时间】:2018-11-26 11:20:17
【问题描述】:
我正在根据以下示例开发动态模板创建。 example 但我无法获得 html 输出。即)动态内容。 ts 文件:
@Component({
selector: 'product-item',
template: `
<div class="product">
<ng-container *compile="template; context: this"></ng-container>
</div>`,
})
export class DynamicItemComponent {
@Input() content: string = `<a (click)='changeEditor('TEXT')'>Click me</a>`;
@Input() template: string = `{{content}}`;
}
HTML:
<product-item [content]="selectedTemplate.content"></product-item>
如何获得 html 输出。我已经使用了 safethtml 管道,这也不起作用。 提前致谢。
【问题讨论】: