Can I prevent ng-repeat from html encoding / escaping my content in AngularJS 1.2? Or need to write own directive?

Hoppe

How can I prevent ng-repeat from html encoding / escaping my content in AngularJS 1.2? Do I need to write my own directive? I've read that ng-bind-html-unsafe was deprecated in Angular 1.2, but I haven't found conclusive information in regards to using it with ng-repeat. Some info has said to use ng-bind-html, but that didn't work either.

<div ng-repeat="entry in blogEntries" ng-bind-html-unsafe="entry.title">
    <div class="well">
        <div>{{entry.date }}</div> {{entry.title}}
    </div>
</div>

This results in some of my text being displayed as the following, instead of the HTML rendering:

<ul> <li>Blah1 5.1<li> <li>Blah 3<li></ul>

I also tried ng-bind-html

I can upgrade if necessary

Do I need to use the ng-sanitize module in order to use ng-bind-html?

Hoppe

The directive ng-bind-html works but I had to include the sanitize module. I.e.

var blogApp = angular.module('blogApp', ['ngRoute', 'ngSanitize'])
    .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
    ...    
}]);

<div ng-repeat="entry in blogEntries">
    <div class="well">
        <div>{{entry.date}}</div><span ng-bind-html="entry.title"></span>
    </div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

angularJS: Why does binding to scope inside a directive result in lost content of ng-repeat?

来自分类Dev

if statement in ng-repeat directive in AngularJS

来自分类Dev

How do I prevent my program from skipping html2pdf function?

来自分类Dev

在AngularJS ng-repeat中解析HTML?

来自分类Dev

AngularJs将2个键相似数组合并为1个ng-repeat

来自分类Dev

使用AngularJS ng-include或Directive调用html的问题

来自分类Dev

How can we prevent that when I resize my window, my images move using HTML-CSS?

来自分类Dev

angularjs ng-repeat在dom上添加html注释

来自分类Dev

AngularJS-根据ng-repeat中的索引不同的HTML

来自分类Dev

AngularJS:具有不同html标签的ng-repeat

来自分类Dev

AngularJS-ng-repeat中的HTML丢失了模板替换的范围

来自分类Dev

带有ng-repeat AngularJS的动态HTML属性

来自分类Dev

AngularJS-在ng -repeat中管理大量HTML

来自分类Dev

AngularJS:具有不同html标签的ng-repeat

来自分类Dev

使用javascript或angularJS更改html中的ng-repeat值

来自分类Dev

需要使用 ng-repeat 减少 Angularjs 中的 HTML

来自分类Dev

将新的 html 元素插入每个 ng-repeat (AngularJS)

来自分类Dev

AngularJS:2 x <tr>的ng-repeat-无法使用DIV

来自分类Dev

在 AngularJS ng-repeat 中使用 2 个数组的数据

来自分类Dev

如何在AngularJS中使用ng-repeat动态生成ng-model =“ my _ {{$ index}}”“?

来自分类Dev

ng-repeat scope not available to a directive within it

来自分类Dev

如何使用ng-repeat和ng-if在AngularJS中显示或隐藏某些HTML标签

来自分类Dev

AngularJS。嵌套ng-repeat

来自分类Dev

AngularJS ng-repeat rerender

来自分类Dev

AngularJS if statement with ng-repeat

来自分类Dev

AngularJS“垂直” ng-repeat

来自分类Dev

嵌套的ng-repeat angularjs

来自分类Dev

AngularJs。ng-repeat问题

来自分类Dev

AngularJS IF ELSE 与 ng-repeat

Related 相关文章

  1. 1

    angularJS: Why does binding to scope inside a directive result in lost content of ng-repeat?

  2. 2

    if statement in ng-repeat directive in AngularJS

  3. 3

    How do I prevent my program from skipping html2pdf function?

  4. 4

    在AngularJS ng-repeat中解析HTML?

  5. 5

    AngularJs将2个键相似数组合并为1个ng-repeat

  6. 6

    使用AngularJS ng-include或Directive调用html的问题

  7. 7

    How can we prevent that when I resize my window, my images move using HTML-CSS?

  8. 8

    angularjs ng-repeat在dom上添加html注释

  9. 9

    AngularJS-根据ng-repeat中的索引不同的HTML

  10. 10

    AngularJS:具有不同html标签的ng-repeat

  11. 11

    AngularJS-ng-repeat中的HTML丢失了模板替换的范围

  12. 12

    带有ng-repeat AngularJS的动态HTML属性

  13. 13

    AngularJS-在ng -repeat中管理大量HTML

  14. 14

    AngularJS:具有不同html标签的ng-repeat

  15. 15

    使用javascript或angularJS更改html中的ng-repeat值

  16. 16

    需要使用 ng-repeat 减少 Angularjs 中的 HTML

  17. 17

    将新的 html 元素插入每个 ng-repeat (AngularJS)

  18. 18

    AngularJS:2 x <tr>的ng-repeat-无法使用DIV

  19. 19

    在 AngularJS ng-repeat 中使用 2 个数组的数据

  20. 20

    如何在AngularJS中使用ng-repeat动态生成ng-model =“ my _ {{$ index}}”“?

  21. 21

    ng-repeat scope not available to a directive within it

  22. 22

    如何使用ng-repeat和ng-if在AngularJS中显示或隐藏某些HTML标签

  23. 23

    AngularJS。嵌套ng-repeat

  24. 24

    AngularJS ng-repeat rerender

  25. 25

    AngularJS if statement with ng-repeat

  26. 26

    AngularJS“垂直” ng-repeat

  27. 27

    嵌套的ng-repeat angularjs

  28. 28

    AngularJs。ng-repeat问题

  29. 29

    AngularJS IF ELSE 与 ng-repeat

热门标签

归档