angular - 如何在反应式表单控件中使用 html 标签?
问题描述
我有这样的事情:
this.emailForm=new FormGroup({
outcomeSubject: new FormControl('Hi<br />My name is John', Validators.required),
outcomeNotes: new FormControl('<div>Hi</div><div>My name is John</div>', Validators.required)
})
元素是文本区域。如何在文本区域内设置标签?我尝试使用 innerHTML 失败,但仍然看到 html 标签。
提前致谢!
解决方案
就我而言,我找到了一个简单的解决方案,例如
const htmlStr = 'text1\ntext2\ntext3';
this.emailForm=new FormGroup({
outcomeSubject: new FormControl(htmlStr, Validators.required),
outcomeNotes: new FormControl(htmlStr, Validators.required)
})
推荐阅读
- c# - 使用 MemoryStream 通过 WCF MessageContract 将文件上传到 SQL FileStream 在到达服务时为空
- python - Beowulf 集群上未出现进程
- javascript - 如何在函数外访问请求函数中定义的变量
- token - 如何对“create-passenger-name-record-sample-nodejs”Sabre API 示例的密码进行编码?
- r - Rstudio 从文件夹中的某些文件和某些列中提取文件。(首选magrittr)
- javascript - 在 React 中使用 setInterval() 获取过于频繁的 API
- python - Python 与 C 中的递归函数
- vb.net - OleDBCommands:执行两个命令并检查
- python - Pandas 双引号列名
- python - Flash 消息未显示在页面上