0

The content contains some image tag and it worked just fine with the ng-bind-html but I found bug. See my picture below, my JSON contained some iframe tag but the output isn't output the html. Why? ng-bind-html avoid iframe tags?

enter image description here

mike19911
  • 101
  • 1
  • 7

1 Answers1

0

ngBindHtml will pass the HTML through $sce.getTrustedHtml before displaying it. I suspect this is what would be removing the iframe.

According to the docs, $sce.trustAsHtml can be used to avoid this check, so long as you fully trust any HTML coming from this source - an iframe from an untrusted source could likely do a number on nasty things to visitors to your page.

$scope.codeOut = $sce.trustAsHtml(data.html);

Be very careful with this methodology!

UPDATE:

Remember that $sce must be included ...

var someHTML_Directive = ['$sce', function($sce) {
 ...
}];
rfornal
  • 5,072
  • 5
  • 30
  • 42
  • Adjusted the answer to give the answer to this ... information here https://docs.angularjs.org/api/ng/service/$sce – rfornal Dec 07 '14 at 13:02