首页 > Web开发 > 详细

angular 解析html

时间:2015-09-17 19:17:27      阅读:208      评论:0      收藏:0      [点我收藏+]

方法1:写filter

<div ng-bind-html="showContent | html" class="detail-content">    

deliciousApp.filter(html, [$sce, function ($sce) {
     return function (text) {
         return $sce.trustAsHtml(text);
     };
 }]);

 


方法2:

 

<div ng-controller="ExampleController">
 <p ng-bind-html="myHTML"></p>
</div>

angular.module(bindHtmlExample, [ngSanitize])
.controller(ExampleController, [$scope, function($scope) {
  $scope.myHTML =
     I am an <code>HTML</code>string with  +
     <a href="#">links!</a> and other <em>stuff</em>;
}]);

 

 

angular 解析html

原文:http://www.cnblogs.com/xiaotaiyang/p/4817028.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!