ng-bind-html与{{interpolation}}

这是我的问题,优点和缺点是什么?

在我的应用程序中,我正在使用插值法,但出现类似错误

{{::sport.name}} -> NHL Futures & Props

如果我用 ng-bind-html

ng-bind-html="sport.name" -> NHL Futures & Props

在这种情况下ng-bind-html正在做我想要的。但是,这有什么问题吗?

有没有一个比另一个更好?

所以告诉我,我愿意接受建议。

冈扎里

实际上,ng-bind和ng-bind-html之间的主要区别是用例。ng-bind只会显示变量的文本解释,但是ng-bind-html会解释变量中的html。

假设我们在您的范围内有一个变量

 $scope.myText = "<b>Hi</b>";

ng-bind或{{}}将显示

 <b>Hi</b>

ng-bind-html将显示

你好

另一个精度是ng-bind-html可以清理html以防止代码注入。

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

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

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

AngularJS中ng-bind,ng-bind-html,ng-bind-html-unsafe之间的区别?

来自分类Dev

AngularJS中ng-bind,ng-bind-html,ng-bind-html-unsafe之间的区别?

来自分类Dev

ng-bind-html与bind-html-compile?

来自分类Dev

AngularJS ng-bind-html-unsafe替换

来自分类Dev

如何使用ng-bind-html?

来自分类Dev

如何从指令观看ng-html-bind?

来自分类Dev

ng-html-bind省略样式标签

来自分类Dev

ng-bind-html剥离元素属性

来自分类Dev

ng-bind-html无法正常工作

来自分类Dev

ng-bind-html中的AngularJS指令

来自分类Dev

Angular:对ng-bind-html使用transclude

来自分类Dev

Problems with modal and ng-bind-html

来自分类Dev

模态和ng-bind-html的问题

来自分类Dev

$ sce.trustAsHtml与ng-bind-html

来自分类Dev

ng-bind-html剥离元素属性

来自分类Dev

嵌套ng-repeat内的角ng-bind-html

来自分类Dev

ng-repeat中唯一的ng-bind-html

来自分类Dev

ng-bind-html和ng-bind-html-unsafe无法正常工作?

来自分类Dev

使用Angular的ng-bind-html和默认HTML

来自分类Dev

AngularJS:ng-bind-html内的tooltip-html-unsafe

来自分类Dev

内层HTML由angularjs中的ng-bind-html添加

来自分类Dev

使用Angular的ng-bind-html和默认HTML

来自分类Dev

为什么ng-bind-html不显示任何内容?

来自分类常见问题

角度ng-bind-html和其中的指令

来自分类Dev

AngularJS Fade通过ng-bind-html更改了内容

来自分类Dev

使用ng-bind-html时$ index始终为0

来自分类Dev

ng-bind-html-unsafe不起作用

来自分类Dev

输入文本内的ng-bind-html不绑定

来自分类Dev

角ng-bind-html-unsafe表达式