【发布时间】:2020-07-19 02:26:45
【问题描述】:
我将 HTML 存储在一个字符串中并在 HTML 文件中使用它,我使用了 HTML sanitize pipe。
下面是我的字符串
privacyNotice = "<div style=\"color: #ff0000;font-style: italic;\">Before continuing to the Application, you are required to read and acknowledge this Privacy Notice</div>......<div><input type=\"checkbox\" (change)=\"changeAcknowledgeBtnState()\"/><span class=\"pl-5\">I acknowledge terms of the privacy notice</span> </div> <div> <button class=\"ackBtn\" [disabled]=\"disableButton\" (click)=\"changePrivacyNoticeStatus()\">Acknowledge </button> </div>";
下面是html文件代码
<div class="container" [innerHTML]='privacyNotice | safeHtml'>
我通过引用this 示例使用了safeHtml 管道
按钮的 disabled 属性不起作用,并且 changePrivacyNoticeStatus() 也没有被调用
【问题讨论】:
-
您保存字符串而不是显示组件并存储在 json 中的任何具体原因?
标签: html angular typescript angular6 dynamic-html