How to run angular change detection manually ?

Anil Kumar
Mar 3, 2024

--

By injecting change detector ref in constructor then calling function detectChanges();

.

import { ChangeDetectorRef } from '@angular/core'; 
constructor( private cd: ChangeDetectorRef){

}

checkTheData(){
this.cd.detectChanges();
//this.cd.markForCheck()
}

--

--

Anil Kumar
Anil Kumar

Written by Anil Kumar

Software Engineer| Angular Advocate | Cyclist

No responses yet