1、将此过滤器添加到ng-bind-html所绑定的数据中,便实现了在数据加载时对于html标签的自动转义。
<div ng-repeat="item in list" >
<div ng-bind-html="item.content |trustHtml"></div>
</div>
2.项目中如果ng-repeat = “item in list”
<li ng-repeat="item in msgList" class="clr" >
<div class="chat-dialog-time" ng-show= "item.send_time1 != ''">{{item.send_time1}}</div>
<!--<div ng-class="{true: 'chat-dialog-news-mine', false: 'chat-dialog-news-other'}[{{item.isOwn}}]"
msgId="{{item.imdn_id}}">-->
<div ng-class="{'chat-dialog-news-mine':{{item.isOwn}},'chat-dialog-news-other':{{!item.isOwn}},
'chat-dialog-news-file':{{item.content_type == 6}},'chat-dialog-news-mine-file':{{item.isOwn}}&&{{item.content_type == 6}},
'chat-dialog-news-other-file':{{!item.isOwn}}&&{{item.content_type == 6}}}" msgId="{{item.imdn_id}}">
<div contextmenu="supermenu" ng-right-click="decrementRight($event,item)">
<i class="icon warn-icon" ng-if="item.isWarn" ng-click="reSendFile(item)"></i>
<i ng-class="{true: 'icon {{item.status}}', false: ''}[{{item.isOwn && item.status !== ''}}]"></i>
<i ng-class="{true: 'bubble-icon right-icon', false: 'bubble-icon left-icon'}[{{item.isOwn}}]"></i>
<span compile='item.content|trustHtml' ng-click="newsClick($event, item)"
ng-dblclick="newsDBClick($event, item)"></span>
</div> <!--<span ng-if="!item.isWarn" ng-show="{{item.need_read_report==1||item.need_read_report}}"
ng-class="{true: 'chat-news-read', false: 'chat-news-unread'}[{{item.is_read==1}}]">-->
<!--{{item.is_read_report==1?'已读':'未读'}}-->
<!--</span>-->
</div>