Javascript 通过使用角度显示内容
我正在使用Javascript 通过使用角度显示内容,javascript,angularjs,Javascript,Angularjs,我正在使用Angularjs在我的应用程序中构建comments功能。因此,我在显示数据时遇到问题。我从服务器获取的数据如下所示: This is the core collection of directives you would use in your template code to build an AngularJS application.\n\nSome examples include: ngClick, ngInclude 数据包含\n。它表示新行。用于显示我正在
Angularjs
在我的应用程序中构建comments
功能。因此,我在显示数据时遇到问题。我从服务器获取的数据如下所示:
This is the core collection of directives you would use in your template
code to build an AngularJS application.\n\nSome examples include: ngClick, ngInclude
数据包含\n
。它表示新行
。用于显示我正在使用ng bind html
指令和$sce.trustAsHtml(数据)的数据代码>。但数据显示在同一行中,而不是添加新行
有人能帮我吗。默认情况下,HTML中的空格是折叠的。为了避免这种情况,您应该使用
<p>
lots of text
with new lines
look like this
</p>
大量文本
用新台词
像这样
使用
大量文本
用新台词
像这样
大量文本
用新台词
像这样
参考:而不是使用
<pre>
lots of text
with new lines
look like this
</pre>
lots of text
with new lines
look like this
data.replace("\n","<br>");