首页 > 其他分享 >angularjs解析html字符串

angularjs解析html字符串

时间:2022-11-24 17:37:25浏览次数:61  
标签:ng content html angularjs 字符串 解析 angular


参考链接

​https://docs.angularjs.org/api/ngSanitize​

首先下载angular-sanitize.min.js,下载地址:

​https://github.com/angular/bower-angular-sanitize​

添加解析函数

//解析html字符串
$scope.deliberatelyTrustDangerousSnippet = function(content) {
return $sce.trustAsHtml(content);
};

使用ng-bind-html配合函数进行解析

<div class="content"
ng-bind-html="deliberatelyTrustDangerousSnippet(que.content)">
</div>


标签:ng,content,html,angularjs,字符串,解析,angular
From: https://blog.51cto.com/u_15890522/5884380

相关文章