Angular 使用带转义元素属性的innerHTML

Angular 使用带转义元素属性的innerHTML,angular,Angular,嗨,我有一个来自rest服务器的html响应,如下所示: <h3>Center Align</h3>\n<p style=\"text-align: center;\">This is a paragraph. It is center aligned. Center is, but nature, a fence sitter. A flip flopper. It has a difficult time making up its mind. It wa

嗨,我有一个来自rest服务器的html响应,如下所示:

<h3>Center Align</h3>\n<p style=\"text-align: center;\">This is a paragraph. It is center aligned. Center is, but nature, a fence sitter. A flip flopper. It has a difficult time making up its mind. It wants to pick a side. Really, it does. It has the best intentions, but it tends to complicate matters more than help. The best you can do is try to win it over and hope for the best. I hear center align does take bribes.</p>
Center Align\n

这是一个段落。它是中心对齐的。中心,但自然,是一个篱笆看护者。人字拖。它很难下定决心。它想选择一方。真的,是的。它有最好的意图,但它往往使事情复杂化,而不是帮助。你所能做的最好的事情就是努力赢得它,并期待最好的结果。我听说中锋确实受贿

当我使用时,innerHTML呈现为:

<h3>Center Align</h3>
<p>
This is a paragraph. It is center aligned. Center is, but nature, a fence sitter. A flip flopper. It has a difficult time making up its mind. It wants to pick a side. Really, it does. It has the best intentions, but it tends to complicate matters more than help. The best you can do is try to win it over and hope for the best. I hear center align does take bribes.
</p>
居中对齐

这是一段。它是中心对齐的。中心,但自然,是一个篱笆看护者。人字拖。它很难下定决心。它想选择一方。真的,是的。它有最好的意图,但它往往使事情复杂化,而不是帮助。你所能做的最好的事情就是努力赢得它,并期待最好的结果。我听说中锋确实受贿。

缺少
标记的转义属性,因此我有一个空的
,而不是

有没有办法用属性呈现此内容?

用于处理HTML。默认情况下是不安全的

constructor(private s: DomSanitizer) {
  this.text = 'my HTML';
  this.text = s.bypassSecurityTrustHtml(this.text);
}