1. 程式人生 > >Angularjs(1.x)和Angular(2+)數據臟檢測之間的區別

Angularjs(1.x)和Angular(2+)數據臟檢測之間的區別

ons about 之間 loop 是否 imp temp some its

轉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+)數據臟檢測之間的區別