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

<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);
    }; 
    

}
                      

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

posted @ 2015-08-07 16:57  leejersey  阅读(3665)  评论(0编辑  收藏  举报