NG-的bind-HTML和NG绑定HTML的不安全不工作? [英] ng-bind-html and ng-bind-html-unsafe is not working?

查看:91
本文介绍了NG-的bind-HTML和NG绑定HTML的不安全不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有我使用angular.1.3.0第一。然后,我有,

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

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

它的工作原理,但它连接codeS的HTML。然后我尝试,

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?

推荐答案

请检查该工作示例: HTTP ://jsfiddle.net/Shital_D/b9qtj56p/6/

下载文件 - 角sanitize.js并将其包含在您的应用程序

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>

这篇关于NG-的bind-HTML和NG绑定HTML的不安全不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆