简体   繁体   中英

ng-bind-html and ng-bind-html-unsafe is not working?

First of all I am using angular.1.3.0. Then I have,

<td class="vcenter" >{{data.videos}}</td>

It works but it encodes the html. Then I tried,

<td class="vcenter" ng-bind-html="data.videos"></td>

But It showed nothing. Then I tried,

<td class="vcenter" ng-bind-html-unsafe="data.videos"></td>

It also shows nothing. What I am missing?

Please check this working example: http://jsfiddle.net/Shital_D/b9qtj56p/6/

Download file - angular-sanitize.js and include it in your app.

var app = angular.module('myApp', ["ngSanitize"]);       

app.controller('myController', function($scope,$compile) {
    $scope.html = '<p>Your html code</p>';
});

<div ng-app="myApp">
     <div ng-controller="myController">
     <p ng-bind-html="html"></p>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM