如何将多行添加到 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. &#xa; Line1');
  }
  return this.rtePlaceholder;
 }

现在我运行 into this problem,我得到 SafeValue must use [property]=binding although I'm already using property binding。 (另一个SA question about thiseven another one

但这些问题主要是关于innerhtml(一个是关于iframe 的src),但我从来没有得到任何这些。

所以我的问题是:这是获取角度的多行属性的正确方法吗?如果是这样,我该如何正确地逃避它?如果没有,我还能如何获得多行数据属性以在 Angular 中呈现?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)