1

I read many articles about change detection but didn't get clear picture how does it work and renders view. Like in react we have virtual dom and diff algorithm which renders only part of UI that has been changed by creating dom patch so similarly how does angular know which part of UI needs to be changed.

How does changes detection decide what change will be rendered/replaced in view?

4

1 回答 1

3

每个组件都有一个关联的变化检测器对象,Angular 在运行时创建。更改检测器对象跟踪所有模板绑定。当变更检测运行时,默认情况下,它会脏检查每个变更检测器对象中的每个模板绑定——即,它将先前的值与当前值进行比较。如果检测到更改,则将新值传播到 DOM。因此,如果只有一处更改,则仅更新 DOM 的一部分。如果发现更改,则不会重新渲染整个视图……只有更改的部分受到影响。

我更长的答案:https ://stackoverflow.com/a/34570122/215945

于 2016-04-12T18:47:28.447 回答