In this article, We will explore Change Detection Mechanisms in Angular.
The Basic mechanism of change Detection is to perform a check against two-state,one is the current State, the other is a new state if any of the states is different from others then something has changed, so we need to update or re-render the view.
Angular performs change Detection on all the components from top to bottom whenever a change detects in the app.
1. The developer is making changes to the model (like a component’s bindings).
2. Angular’s change detection kicks in to detect the changes.
3. Change detection goes through every component in the component tree (from top to bottom) to check if the model depends on change.
4. If Yes, it will update the component.
5. Angular updates the component’s view (DOM).
the way angular perform change detection is from the top and continuing until it reaches the bottom.
there are two types of change detection strategies,the Default, and the onPush.
changeDetection: ChangeDetectionStrategy.Default
changeDetection: ChangeDetectionStrategy.OnPush
private _changeDetectorRef: ChangeDetectorRef
this._changeDetectorRef.markForCheck();
this._changeDetectorRef.detach()
this._changeDetectorRef.detectChanges();
this._changeDetectorRef.checkNoChanges();
this._changeDetectorRef.reattach();
Hope this article helps you guys
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular