如何解决如何将多行添加到 angular
我在 angular 项目中使用 Quill Editor,我需要多行占位符。由于 Quill 通过 ::before
呈现占位符,我认为应该直接实现这一点,如 this SA question about multiline data attributes 中所述。
我通过 Json 从后端获取占位符:
placeholder : 'Line number 1 
 Line number 2'
当我将其作为 placeholder
的值时,这些“新行”指示符不会呈现为新行,而是呈现为文本。
<quill-editor [placeholder]="rtePlaceholder">
当我使用 Dev Tools 编辑页面并将字符串从 JSON 复制粘贴到生成的 data-placeholder
属性时,它会正确呈现。
我想我可能需要绕过 domsanitizer somehow as said in this SA question
<quill-editor [placeholder]="getRtePlaceholder()">
getRtePlaceholder() {
// hardcoded string to better show it,here will then be the value from the JSON.
this.rtePlaceholder = this.sanitizer.bypassSecurityTrustHtml('Line 1. 
 Line1');
}
return this.rtePlaceholder;
}
现在我运行 into this problem,我得到 SafeValue must use [property]=binding although I'm already using property binding
。 (另一个SA question about this和even another one)
但这些问题主要是关于innerhtml(一个是关于iframe 的src),但我从来没有得到任何这些。
所以我的问题是:这是获取角度的多行属性的正确方法吗?如果是这样,我该如何正确地逃避它?如果没有,我还能如何获得多行数据属性以在 Angular 中呈现?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。