我正在尝试使用patchValue
方法为控件设置一个字符串值。字符串值包含 HTML 标记,但由于某种原因,HTML 标记被翻译为纯文本。
<textarea rows="5" name="myField" formControlName="myField" readonly></textarea>
const htmlStr = '<p>HTML Content HERE</p>'
// assuming the form group instance already created
this.form.get('myField').patchValue(this.htmlStr);
Angular API 文档没有过多地说明patchValue如何处理 HTML 值,尽管它非常通用。