【发布时间】:2016-08-11 16:57:26
【问题描述】:
我想在引导表中显示一些文本。由于我需要<br/>-tags 来显示彼此下方的所有不同链接,因此文本应该被解析为 HTML。使用我的代码查看this Plunker。
如您所见,我使用了默认的 ng-bind 指令以及已弃用的 ng-bind-html,但文本要么显示为纯文本,要么根本不显示。
你们能告诉我如何显示解析为 HTML 的文本吗?
这里是我的 HTML 表格的代码:
<table class="table">
<thead>
<tr>
<th>Method</th>
<th>$scope.other</th>
<th>$scope.links</th>
</tr>
</thead>
<tbody>
<tr>
<td>ng-bind</td>
<td>{{other}}</td>
<td>{{links}}</td>
</tr>
<tr>
<td>ng-bind-html</td>
<td ng-bind-html="other"></td>
<td ng-bind-html="links"></td>
</tr>
</tbody>
</table>
匹配的控制器:
app.controller('TestController', function($scope){
$scope.links = 'https://www.google.com <br/> https://angularjs.org/ <br/> \
https://www.google.com <br/> https://angularjs.org/ <br/> \
https://www.google.com <br/> https://angularjs.org/ <br/>';
$scope.other = "sample Text";
});
【问题讨论】:
标签: javascript html angularjs