读取角度表达式json数据中的br或pre或html标记

to read br or pre or html tag in angular expression json data

本文关键字:br pre html 标记 表达式 json 数据 读取      更新时间:2023-09-26

/* sentence = "sdf vfgfhgjhkj,k ghhjjhjhjhj fgghghghgvvvv
              ssdfgbghg vvffffffffffffffffffffffffbbbfbfffffffff
              ccccccccccccccccccccccccccccccccccccccccccc"
<table class="table-responsive">
 <th>notice</th>
<tr ng-repeat stment in data.note.statements>
  <td>{{stment.sentence}}</td>
  </tr>
</table>

我希望角度表达式能够按原样绑定json数据,换行符也会按原样出现。

首先用'n:拆分长句

$scope.displayData = $scope.data.note.statements.split(''n');

然后在TABLE 中显示拆分数据

 <table class="table-responsive">
      <th>notice</th>
      <tr ng-repeat="item in displayData">
           <td>{{item}}</td>
      </tr>
 </table>

Manish,

不确定它会工作,但尝试使用:ng-bind-html

<table class="table-responsive">
 <th>notice</th>
<tr ng-repeat="stment in data.note.statements">
  <td ng-bind-html="'<pre>' + stment.sentence + '</pre>'"></td>
  </tr>
</table>