如何在字符串中添加新行:
HTML:
<div class="col-md-8 col-sm-8">
{{ getLastAction(activity) }}
</div>
AngularJS:
$scope.getLastAction= function (activity) {
if (activity) {
let desc= activity.Desc;
let first= activity.First;
let res= desc+ '<br>' + first;
return res;
}
}
我试图放<br>
和\ n,但是都没有。
答案 0 :(得分:0)
使用ng-bind-html指令。
<div class="col-md-8 col-sm-8">
<span class="test" ng-bind-html="test"></span>
</div>
JS
$scope.getLastAction= function (activity) {
if (activity) {
let desc= activity.Desc;
let first= activity.First;
let res= desc+ '<br>' + first;
$scope.test = res;
}
}