我想将从数据库中保存的br转换为前端的换行符。这是我到目前为止得到的:
<div ng-repeat="desc in items.description.split(',')"><span class="pre-break">{{desc}}</span></div>
.CSS:
.pre-break{
white-space: pre-wrap !important;
}
数据库中的示例数据:
6 pcs <br/> 2 pc thigh, 2 pc wing, 2 pc chops
但结果还是这样的:
6 pcs <br/> 2 pc thigh | 2 pc wing | 2 pc chops
我将如何转换 br 标签?
你可以像 ng-bind-html 一样使用 ng-bind-html
<div ng-repeat="desc in items.description.split(',')">
<span class="pre-break">
<p ng-bind-html="desc"></p>
</span>
</div>