大佬教程收集整理的这篇文章主要介绍了angularjs – AngBind中ngBind,ngBindHtm和ngBindTemplate之间的差异,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
你们中有谁能解释一下ngBind,ngBindHtm& ngBindTemplate在Angular JS中有一个例子?
ngBind用于使用给定表达式的值替换指定HTML元素的文本内容。例如,如果你有一个html,如下所示< b ng-bind =“name”>< / b>并在您的控制器中给出名称为$ scope.name =“John”的值。这将导致< b> John< / b>。但是您不能在单个html元素中使用多个值进行绑定。例如
$scope.first_name = "John"; $scope.second_name = "D"; <b ng-bind="first_name second_name"></b>
这不会将结果作为< b> John D< / b>只绑定first_name。因此,为了绑定多个值,我们可以使用Ng-bind-template
NG-绑定模板
$scope.first_name = "John"; $scope.second_name = "D"; <b ng-bind-template="{{first_name second_namE}}"></b>
这导致< b> John D< / b>
但是您无法在这两个表单中呈现html标签。对于渲染html模板,我们可以使用Ng-bind-html。
NG绑定,HTML
$scope.name = "<b>John</b>"; <div ng-bind-html="name"></div>
以上是大佬教程为你收集整理的angularjs – AngBind中ngBind,ngBindHtm和ngBindTemplate之间的差异全部内容,希望文章能够帮你解决angularjs – AngBind中ngBind,ngBindHtm和ngBindTemplate之间的差异所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。