0

我正在尝试使用变量$scope.text插入此 html 代码:

<ul>
  <li>
    <div data-drop="true" ng-model='list1' 
         data-jqyoui-options="optionsList1" jqyoui-droppable="{multiple:true}">
      <div ng-repeat="item in list1" ng-show="item.title" 
           data-drag="{{item.drag}}" data-jqyoui-options="{revert: 'invalid'}" 
           ng-model="list1" jqyoui-draggable=\"{index: {{$index}},animate:true}\">
           {{item.title}}</div>
    </div>
  </li>
</ul>

在 Angularjs 的 html 文件中,我使用:<div ng-bind-html="text"></div>

问题是,在我的 Web Inspector 中只有:

<ul><li>
     <div >{{item.title}}</div>
</li></ul>

如何显示所有参数?

4

1 回答 1

0

The solution is $sanitize:

HTML file:

<div ng-bind-html="deliberatelyTrustDangerousSnippet()"></div>

Controller file:

$scope.deliberatelyTrustDangerousSnippet = function() {
    return $sce.trustAsHtml($scope.texto);
};

Installing Sanitize:

npm install angular-sanitize

于 2014-12-29T09:01:07.837 回答