Angularjs 角度清理/ng绑定html不工作?
我已经设置了一个中继器,只要里面没有html,就可以获取要显示的数据 我已经加入了Angularjs 角度清理/ng绑定html不工作?,angularjs,ng-bind-html,ngsanitize,Angularjs,Ng Bind Html,Ngsanitize,我已经设置了一个中继器,只要里面没有html,就可以获取要显示的数据 我已经加入了angular sanitize.js,并尝试使用ng bind html 但是在span中没有显示任何内容,仅在ng bind html属性中显示。看来消毒液不起作用了 我了解到这需要添加到应用程序依赖项中,但不确定在哪里这样做 我刚刚在angular网站上完成了tut的工作,所以目前只设置了一个非常基本的控制器。我的解决方案是从这里下载js文件 我一直在用我在angular git回购中找到的 您需要包括an
angular sanitize.js
,并尝试使用ng bind html
但是在span中没有显示任何内容,仅在ng bind html
属性中显示。看来消毒液不起作用了
我了解到这需要添加到应用程序依赖项中,但不确定在哪里这样做
我刚刚在angular网站上完成了tut的工作,所以目前只设置了一个非常基本的控制器。我的解决方案是从这里下载js文件 我一直在用我在angular git回购中找到的
{{}
我的解决方案与塞格莱斯潘相反。这是使用鲍尔版本的Angular Sanitize
bower install angular-sanitize
我也遇到过类似的问题,但我的问题有点奇怪。只有输入标记未呈现,而其他所有内容包括
<h3></h3>
<em></em>
我需要补充一点
textAngular-sanitize.min.js
在输入标记工作之前将其添加到我的项目。这确实令人沮丧,因此我希望这能帮助任何处于类似情况的人在使用指令时遇到此问题,并且解决方案没有在代码中使用“替换” `在templateUrl视图中的一个div上使用了ng html bind
appDirectives.directive('helpText', [function () {
return {
restrict: 'E',
//replace: true, // With this uncommented it does not work!
scope: {
displayText: '='
},
templateUrl: '/web/form/helptext',
link: function (scope) {
}
};
}]);
你能展示一下你在JSFIDLE上试过什么吗看起来我使用的angular-sanatize.js文件不正确,我是从git repo中获取的,但是当我获取在js FIDLE上使用的文件时,它现在可以正常工作了。感谢你将这些步骤放进去。这样更容易理解和理解。对我来说也很好用。谢谢。谢谢。效果很好。这应该是公认的答案(有100多张赞成票为什么不?!)4。确保你的同事没有偷偷溜进一个
item.title=$sce.trustAsHtml(item.title)
appDirectives.directive('helpText', [function () {
return {
restrict: 'E',
//replace: true, // With this uncommented it does not work!
scope: {
displayText: '='
},
templateUrl: '/web/form/helptext',
link: function (scope) {
}
};
}]);