在angularjs NG绑定和NG-斗篷之间的差异斗篷、绑定、差异、angularjs

2023-09-13 03:04:34 作者:宸

在这个问题为什么NG绑定优于{{} }在角?我明白了 {{}} NG-绑定之间的差异。在另一方面,我可以使用 NG-斗篷而不是 NG-绑定

In this question why ng-bind is better than {{}} in angular? I understood the differences between {{}} and ng-bind. On the other hand I can use ng-cloak instead of ng-bind.

现在我的问题是什么是 NG-绑定 NG-斗篷

Now my question is what is the differences between ng-bind and ng-cloak?

推荐答案

他们做同样的工作比较。

They do the same job relatively.

综观API文档,你会发现它们是什么究竟。

Looking at api docs, you may find what are they exactly.

该ngCloak指令通过在其原始(未编译)形式的浏览器,而你的应用程序加载被短暂显示用于prevent的角度HTML模板。使用这个指令以避免造成HTML模板显示不良闪烁效果。

The ngCloak directive is used to prevent the Angular html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the html template display.

在NG-斗篷指令隐藏所有的页面上的元素的内置角速度指令包含指令

The ng-cloak directive is a built-in angular directive that hides all of the elements on the page that contain the directive.

<div ng-cloak>
<h1>Hello {{ foo }}</h1>
</div>

在浏览器中完成装载和模板的编译阶段是渲染,角将删除ngCloak元素属性和元素将变得可见。

After the browser is done loading and the compile phase of the template is rendering, angular will delete the ngCloak element attribute and the element will become visible.

的ngBind属性告诉角来代替指定的HTML元素的与给定的前pression的值的文本内容,并更新文本内容时的该前pression的值发生变化。

The ngBind attribute tells Angular to replace the text content of the specified HTML element with the value of a given expression, and to update the text content when the value of that expression changes.

使用 NG-绑定而不是 {{}} 将prevent被呈递的 {{}} 从显示出来的而不是渲染空元素。从上面的例子可以改写为将prevent以下从闪烁的页面 {{}}

Using ng-bind instead of {{ }} will prevent the unrendered {{ }} from showing up instead of empty elements being rendered. The example from above can be rewritten to the following which will prevent the page from flickering with {{ }}:

<div>
<h1>Hello <span ng-bind="foo"></span></h1>
</div>