简体   繁体   English

ng-bind-html和ng-bind-html-unsafe无法正常工作?

[英]ng-bind-html and ng-bind-html-unsafe is not working?

First of all I am using angular.1.3.0. 首先,我正在使用angular.1.3.0。 Then I have, 那我有

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

It works but it encodes the html. 它可以工作,但可以对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/ 请检查以下工作示例: http : //jsfiddle.net/Shital_D/b9qtj56p/6/

Download file - angular-sanitize.js and include it in your app. 下载文件-angular-sanitize.js并将其包含在您的应用程序中。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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