Javascript 在AngularJS 1.2中,我可以防止ng repeat对我的内容进行html编码/转义吗?还是需要编写自己的指令?
如何在AngularJS 1.2中防止html编码/转义我的内容时重复ng?我需要自己写指令吗?我已经读到Angular 1.2中不推荐使用Javascript 在AngularJS 1.2中,我可以防止ng repeat对我的内容进行html编码/转义吗?还是需要编写自己的指令?,javascript,html,angularjs,html-encode,Javascript,Html,Angularjs,Html Encode,如何在AngularJS 1.2中防止html编码/转义我的内容时重复ng?我需要自己写指令吗?我已经读到Angular 1.2中不推荐使用ng bind html unsafe,但是我还没有找到关于将其与ng repeat一起使用的结论性信息。一些信息说要使用ng bind html,但这也不起作用 <div ng-repeat="entry in blogEntries" ng-bind-html-unsafe="entry.title"> <div class="
ng bind html unsafe
,但是我还没有找到关于将其与ng repeat一起使用的结论性信息。一些信息说要使用ng bind html,但这也不起作用
<div ng-repeat="entry in blogEntries" ng-bind-html-unsafe="entry.title">
<div class="well">
<div>{{entry.date }}</div> {{entry.title}}
</div>
</div>
{{entry.date}{{entry.title}
这将导致我的某些文本显示为以下内容,而不是HTML呈现:
<ul> <li>Blah1 5.1<li> <li>Blah 3<li></ul>
- blah15.1
- blah3
我还尝试了ng bind html
如有必要,我可以升级
我是否需要使用ng sanitize模块才能使用
ng bind html
?指令ng bind html
有效,但我必须包含sanitize模块。即
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>
var blogApp=angular.module('blogApp',['ngRoute','ngSanitize']))
.config(['$routeProvider','$locationProvider',函数($routeProvider,$locationProvider){
...
}]);
{{entry.date}
ng repeat
在内部html中设置,并且ng bind
也设置内部html,因此我认为两者都有意义……这是一个重复。请参阅前面的答案:@jpillora ng bind html不起作用。如果这是个骗局,请提供答案。我可以复制并粘贴我链接的答案,尽管那是作弊。基本上,它是如何使用包括该模块(在1.2中)在内的内容是正确的。看见