Change Detection means updating the view (DOM) when the data has changed.
There are two types of change detection strategy
1. OnPush
2. Default
OnPush :
Use the CheckOnce strategy, meaning that automatic change detection is deactivated until reactivated by setting the strategy to Default (CheckAlways). Change detection can still be explicitly invoked. This strategy applies to all child directives and cannot be overridden.
With onPush, the component only depends on its inputs and embraces the immutability, the change detection strategy will kicks in when:
- The Input reference changes;
- An event originated from the component or one of its children;
- Run change detection explicitly (componentRef.markForCheck());
- Use the async pipe in the view.
Default:
Use the default CheckAlways strategy, in which change detection is automatic until explicitly
deactivated.
No comments:
Post a Comment