所以我在index.html中有下一个div:
...
<div ng-include src="'templates/blocks.html'" ng-controller='Foo'></div>
...
Foo Controller 在“bars”属性下保存一个 html 片段数组。
blocks.html 看起来像:
<div class="block" ng-repeat="bar in bars">
<div ng-bind-html-unsafe="{{bar}}"></div>
</div>
我得到的是 html 作为 div 中带有“block”类的文本,这意味着它不会被评估为 html。
谢谢。
最佳答案
ng-bind-html-unsafe 在 1.2 中被删除。使用 ng-bing-html 代替并删除花括号,就像 Sebastian 所说的那样。
将 ngSanitize 模块作为应用程序的依赖项包含在内,并且不要忘记包含其 JS //ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-sanitize.js。
关于javascript - Angular ng-repeat 和 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23303401/