ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: code example
Example 1: angular ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.
constructor(private ref: ChangeDetectorRef){}
ngAfterContentChecked() {
this.ref.detectChanges();
}
Example 2: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: [object Object]'. Current value: 'ngIf: true'.
import { ChangeDetectorRef,AfterContentChecked} from '@angular/core'
export class example implements OnInit, AfterContentChecked {
ngAfterContentChecked() : void {
this.changeDetector.detectChanges();
}
}