Non*_*Non 6 angularjs ng-bind-html angularjs-interpolate
这是我的问题,有什么优点和缺点?
在我的应用程序中我使用插值但我得到这样的错误
{{::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>";
Run Code Online (Sandbox Code Playgroud)
将显示ng-bind或{{}}
<b>Hi</b>
Run Code Online (Sandbox Code Playgroud)
将显示ng-bind-html
你好
另一个精度是ng-bind-html可以清理你的html以防止代码注入.
| 归档时间: |
|
| 查看次数: |
3005 次 |
| 最近记录: |