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?
Asked
Active
Viewed 81 times
0

mike19911
- 101
- 1
- 7
-
"See my picture below": what if I can't see images? – Blackhole Dec 07 '14 at 12:54
-
The image is particularly small. If this is from the console, see if you can select it, then copy/paste here. – rfornal Dec 07 '14 at 12:57
1 Answers
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