Angular 中 ng-bind 和插值 {{}} 的区别 [英] Difference between ng-bind and interpolation {{}} in Angular
问题描述
有什么区别吗{{ }} 和 ng-bind 角度.
Is there any difference between {{ }} and ng-bind in angular.
我对 Angular 很陌生.我从使用 {{ }} 开始,然后在文档中找到了 ng-bind.我认为他们做同样的工作,但为什么要额外的指令,如果没有,请说出不同之处.
I am quite new to Angular. I started with using {{ }} and then in the documentation i find ng-bind. I think they do the same work but then why an extra directive, if not then please tell the difference.
推荐答案
官方文档中有一些提示:https://docs.angularjs.org/api/ng/directive/ngBind
There is some hint in the official docs: https://docs.angularjs.org/api/ng/directive/ngBind
通常情况下,您不直接使用 ngBind,而是使用双卷曲标记,如 {{ expression }} 类似但更少详细.
Typically, you don't use ngBind directly, but instead you use the double curly markup like {{ expression }} which is similar but less verbose.
最好使用 ngBind 而不是 {{ expression }} 如果浏览器会暂时以原始状态显示模板在 Angular 编译它之前.由于 ngBind 是一个元素属性,它在页面加载时使绑定对用户不可见.
It is preferable to use ngBind instead of {{ expression }} if a template is momentarily displayed by the browser in its raw state before Angular compiles it. Since ngBind is an element attribute, it makes the bindings invisible to the user while the page is loading.
这篇关于Angular 中 ng-bind 和插值 {{}} 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!