码迷,mamicode.com
首页 > Web开发 > 详细

angular 解析html

时间:2015-09-17 19:20:13      阅读:158      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!