javascript - Why is my $sce.trustAsHtml content being rendered as plain text? -


i not sure missing here reason iframe being rendered text instead of html. using angular 1.3.15.

here view:

<span ng-bind-html="question.questionlabel"></span> 

here controller:

vm.questionlabel = $sce.trustashtml('<iframe width="560" height="315" src="https://www.youtube.com/embed/3al9qqwrm7e" frameborder="0" allowfullscreen></iframe>'); 

and following getting rendered page in text form:

<iframe width="560" height="315" src="https://www.youtube.com/embed/3al9qqwrm7e" frameborder="0" allowfullscreen></iframe> 

i have injected ngsanitize controller well. see no errors in logs. @ loss. can please help?

thanks!

use ngsanitize

please check working example: http://plnkr.co/edit/rpoznm12iwvnzjv6mio8?p=preview

download file - angular-sanitize.js , include in app.

var app = angular.module('myapp', ["ngsanitize"]);         app.controller('mycontroller', function($scope) {     $scope.html = '<p>your html code</p>'; });  <div ng-app="myapp">      <div ng-controller="mycontroller">         <p ng-bind-html="html"></p>      </div> </div> 

Comments