角的sanitize / NG绑定,HTML不工作? [英] Angular sanitize / ng-bind-html not working?

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

问题描述

我有一个中继器设置,并能得到,只要有它在没有HTML数据显示。

我已经包括角sanitize.js ,并使用 NG-绑定-HTML

但没有什么是跨度内显示,仅在 NG-绑定-HTML 属性。所以它看起来像sanitize方法是行不通的,

我读到这需要被添加到应用程序的依赖关系,但我不知道在哪里做。

我刚刚被通过的角部位的啧啧工作,所以只需要在一分钟建立一个非常基本的控制器。


解决方案

  1. 您需要包括角sanitize.js
    <一href=\"http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-sanitize.js\">http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-sanitize.js


  2. 添加 ngSanitize 你模块依赖


      

    VAR对myApp = angular.module('对myApp',['ngSanitize']);



  3. 不要使用{{}}在属性


      

    &LT; H1 NG绑定-HTML =item.title&GT;&LT; / H1&GT;



I've got a repeater set up and can get data to display as long as there is no html within it.

I've included angular-sanitize.js and have tried using ng-bind-html

But nothing is displayed within the span, only within the ng-bind-html attribute. So it looks like sanitise isn't working,

I read that this needs to be added to the app dependencies but am not sure where to do so.

I've just been working through the tut on the angular site so only have a very basic controller set up at the minute.

解决方案

  1. You need to include the angular-sanitize.js http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-sanitize.js

  2. Add 'ngSanitize' to you module dependencies

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

  3. Don't use the {{}} in the attribute

    <h1 ng-bind-html="item.title"></h1>

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

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