October 2017
Intermediate to advanced
280 pages
6h 50m
English
The change detection strategies that Angular provides are Default and OnPush. We will describe how we can take advantage of OnPush in detail, since it is very powerful when working with immutable data.
Now, let's import the TypeScript enum, which can be used to configure the strategy used for the individual components:
// ch5/change_detection_strategy_broken/app.ts
import {ChangeDetectionStrategy} from '@angular/core';
Now, we can configure the TodoList component to use the OnPush strategy:
@Component({
selector: 'todo-list',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `...`,
styles: [...]
})
class TodoList { ... }
This way, the change detection will be skipped until the ...
Read now
Unlock full access