0

I'm trying to insert this html code with a variable $scope.text:

<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>

In html file of Angularjs I use: <div ng-bind-html="text"></div>

And the problem is, that in my Web Inspector only have:

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

How can i show all parameters?

New Dev
  • 48,427
  • 12
  • 87
  • 129

1 Answers1

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

  • If you include `ngSanitize` module, you don't need the `$sce.trustAsHtml()` in the controller as well. `ngSanitize` will do this by default. – Davin Tryon Dec 29 '14 at 09:02