Angularjs(1.x)和Angular(2+)数据脏检测之间的区别
Posted jim520
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Angularjs(1.x)和Angular(2+)数据脏检测之间的区别相关的知识,希望对你有一定的参考价值。
转2篇个人认为写的很好的:
Angularjs(1.x) http://www.cnblogs.com/likeFlyingFish/p/6183630.html
Angular(2+) https://blog.csdn.net/u011256637/article/details/71056731?utm_source=itdadao&utm_medium=referral
以及总结:(原出处:https://blog.angular-university.io/how-does-angular-2-change-detection-really-work )
The Angular default change detection mechanism is actually quite similar to Angular 1: it compares the values of templates expressions before and after a browser event to see if something changed. It does so for all components.
But there are also some important differences:
For one there are no change detection loops, or a digest cycle as it was named in Angular 1. This allows to reason about each component just by looking at its template and its controller.
Another difference is that the mechanism of detecting changes in a component is much faster due to the way change detectors are built.
Finally and unlike in Angular 1, the change detection mechanism is customizable.
附翻译:
Angular 默认更改检测机制实际上与Angular 1非常相似:它比较浏览器事件之前和之后的模板表达式的值,以查看是否有更改。它适用于所有组件。
但也存在一些重要的差异:
对于一个没有变化检测循环,或者在Angular 1中命名的脏值循环。这允许仅通过查看其模板及其控制器来推断每个组件。
另一个不同之处在于,由于构建变化检测器的方式,检测组件中的变化的机制要快得多。
最后,与Angular 1不同,更改检测机制是可定制的。
以上是关于Angularjs(1.x)和Angular(2+)数据脏检测之间的区别的主要内容,如果未能解决你的问题,请参考以下文章
第1208期AngularJS 1.x平滑升级Angular实战
AngularJs 1.x和AngularJs2的区别是啥?
AngularJS 1.x 国际化——Angular-translate例子