Dirty Checking (脏值检查) Digest cycle and $scope Digest cycle and $scope First and foremost, AngularJS defines a concept of a so-called digest cycle. This cycle can be considered as a loop, during which AngularJS checks if there are any changes to all t…
今天突然就想写写$digest和$apply,这些都是脏值检查的主体内容. 先以普通js来做一个简单的监控例子吧: var div = ducoment.getElementById("myDiv"); div.addEventListener("click",function(e){ console.log(e); }) 在这里,我们给一个div绑定了个点击事件,并且给这个绑定事件一个回调函数.这里我们就是给了这个div一个监听,当监听到有点击事件发生在此div上…
In this article I will talk in depth about the Angular 2 change detection system. HIGH-LEVEL OVERVIEW An Angular 2 application is a tree of components. An Angular 2 application is a reactive system, with change detection being the core of it. Every c…
When you testing Component rendering, you often needs to call: fixture.detectChanges(); For example: it('should display original title', () => { fixture.detectChanges(); expect(el.textContent).toContain(comp.title); }); it('should display a different…
Dirty Checking (脏值检查) Digest cycle and $scope Digest cycle and $scope First and foremost, AngularJS defines a concept of a so-called digest cycle. This cycle can be considered as a loop, during which AngularJS checks if there are any changes to all t…
今天突然就想写写$digest和$apply,这些都是脏值检查的主体内容. 先以普通js来做一个简单的监控例子吧: var div = ducoment.getElementById("myDiv"); div.addEventListener("click",function(e){ console.log(e); }) 在这里,我们给一个div绑定了个点击事件,并且给这个绑定事件一个回调函数.这里我们就是给了这个div一个监听,当监听到有点击事件发生在此div上…