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

ng-bind-html在ng-repeat中问题的解决办法

时间:2015-08-07 18:38:28      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

<div ng-controller="MyCtrl">
  Hello, {{name}}!
    
    <div class="row" ng-repeat="post in posts">
        <div ng-bind-html="TrustDangerousSnippet(post)">
            <p>{{post.post}}</p>
          </div>
    </div
</div>

js

var myApp = angular.module(‘myApp‘,[]);

function MyCtrl($scope, $sce) {
    $scope.name = ‘Superhero‘;
    var input_data = [];
     input_data.push({post: ‘<h1>bla</h1>‘});

    $scope.posts = input_data;
    $scope.TrustDangerousSnippet = function(post) {
      return $sce.trustAsHtml(post.post);
    }; 
    

}
                      

简单点来说就是当参数传参来解决

ng-bind-html在ng-repeat中问题的解决办法

标签:

原文地址:http://www.cnblogs.com/leejersey/p/4711315.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!