在Angular JS中,表达式变量之前的双冒号有什么作用? [英] What does double colon before expression variable do in angular js?

查看:253
本文介绍了在Angular JS中,表达式变量之前的双冒号有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在angularjs中,表达式变量前的双冒号::是什么,{{ firstName }}{{ ::firstName }}之间的区别是什么?

In angularjs, what is a double colon :: before an expression variable, and what is the difference between {{ firstName }} and {{ ::firstName }}?

推荐答案

来自:它显示为:

一次性绑定语法{{ ::value }}

AngularJS最近在Beta版中删除了一个非常有趣的功能 1.3.0版本:一次渲染数据并使其持久化的能力 不受将来模型更新的影响.这真是个好消息 对于高度关注性能的开发人员!在此更新之前, 我们通常会像这样在DOM中呈现值:

AngularJS dropped a really interesting feature recently in the beta version of 1.3.0: the ability to render data once and let it persist without being affected by future Model updates. This is fantastic news for developers highly concerned with performance! Before this update, we’d typically render a value in the DOM like so:

 <h1>{{ title }}</h1>

使用新的一次性绑定语法,我们引入了双冒号 在我们的价值之前:

With the new one-time binding syntax, we introduce a double-colon before our value:

 <h1>{{ ::title }}</h1>

Angular像往常一样处理DOM,并且一旦该值被 解决了它从内部删除特定属性的问题 $$watchers列表.这对性能意味着什么?很多!这是一个 帮助我们微调应用程序的绝佳补充.

Angular processes the DOM as usual and once the value has been resolved it removes the particular property from its internal $$watchers list. What does this mean for performance? A lot! This is a fantastic addition to helping us fine tune our applications.

众所周知,Angular会变慢,需要绑定约2,000个绑定 进行脏检查的过程.我们可以添加的越少 限制更好,因为绑定可以累加,而无需我们真正注意 它!

It’s known that Angular becomes slower with around 2,000 bindings due to the process behind dirty-checking. The less we can add to this limit the better, as bindings can add up without us really noticing it!

使用单一绑定语法很容易,最重要的是快速. 语法简洁明了,这对于降低 $$watcher开销. Angular要做的工作越少,那么越多 响应,我们的应用程序将变为.

Using the single binding syntax is easy and most importantly fast. The syntax is clear and concise, and a real benefit to lowering the $$watcher overhead. The less work Angular has to do, the more responsive our applications will become.

这篇关于在Angular JS中,表达式变量之前的双冒号有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆