0

How can I add a new line to string:

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;
    }
}

I tried to put <br> and \n but neither worked.

1 Answers1

0

use ng-bind-html directive.

<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;
    }
}
ACD
  • 1,431
  • 1
  • 8
  • 24