Root
Header
Footer
ItemList
Item
Come to Lecture
Understand CD
TaskList: [ { id: 123, description: 'Come to Lecture', isImportant: true, isDone: true }, { id: 456, description: 'Understand CD', isImportant: true, isDone: false }, ... ]
(after code finished)
(user interaction / browser event)
(Change Detection Tree)
<parent>
<child></child>
</parent>
C - time to check one binding
N - amount of bindings
( just in time )
( ahead of time )
$ ng serve $ ng build
$ ng serve --aot $ ng build --prod
@Component({ ..., changeDetection: ChangeDetectionStrategy.OnPush, ... })
constructor(private ref: ChangeDetectorRef) { ... }
Helps to control change detection behavior of current component
Methods:
User interaction
Server communication
Timer event
any Async action
Async action
zone.js
Change Detection
constructor (private ngZone: NgZone) {} public processOutside() { this.ngZone.runOutsideAngular( () => { // do some stuff }); } public goBack(someFunction) { this.ngZone.run(someFunction); }
By Anton Bely
Hello world! My name is Anton Bely and I'm a Product Frontend Engineer. Welcome!