Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
    
Do you have any exceptions in the console ? –  Pavel Kutakov Dec 29 '14 at 8:39
    
Nop.. and the $scope.text have the correct html code.. –  victorlopezsanchez Dec 29 '14 at 8:40
1  
I think this is the way how defaul $sanitize service work. It just removes potentially unsave stuff from your HTML. Check for details and examples: docs.angularjs.org/api/ngSanitize/service/$sanitize –  Pavel Kutakov Dec 29 '14 at 8:46
1  
possible duplicate of Insert HTML into view using AngularJS –  Orel Eraki Dec 29 '14 at 8:50

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
    
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 9:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.