Vin*_*nni 3 rendering typescript angular
如何使用字符串变量(保持模板)呈现 html - Angular4。
样本.component.ts
let stringTemplate = "<div><p>I should be rendered as a HTML<br></p></div>";
Run Code Online (Sandbox Code Playgroud)
sample.component.html应该基于变量stringTemplate 中的元素呈现
注意:stringTemplate不是静态的。将从服务器获取其数据。
小智 5
您可以绑定到innerHtml 属性。
<div [innerHtml]="stringTemplate"></div>Run Code Online (Sandbox Code Playgroud)