我进行了一个 AJAX 调用,它在 JSON 对象中为我提供了一个字符串,其中包含如下格式的文本:
Your girl was in Berkeley with a communist reader. <br> Mine was entombed within boombox and walkman. <br> I was a hoarder, but girl, that was back then. <br> The gloves are off, the wisdom teeth are out. <br> What you on about? <br> I can feel it in my bones. <br> I can feel it in my bones. <br> I'm stronger now, I'm ready for the house. <br> Such a modest mouse. <br> I can't do this alone.
我使用这个字符串在我的网页上填充一个 div,它看起来像这样:
<div class="lyrics-container>{{ the text in the JSON string }} </div>
但是,当用该文本填充 div 时,我得到了确切的字符串,这意味着<br>
s 显示为文本。我希望他们真正发挥作用并打破界限。有没有办法强制浏览器在字符串中解释 HTML?
我正在使用 Angular 来获取数据并填充 div,如果这有什么不同的话。