Friday, May 1, 2020

ExpressionChangedAfterItHasBeenCheckedError



Relevant change detection operations steps
A running Angular application is a tree of components. During change detection Angular performs checks for each component which consists of the following operations performed in the specified order:
fddf

Possible fixes of ExpressionChangedAfterItHasBeenCheckedError:
Asynchronous update: use setTimeout
 setTimeout(() => {
            this.parent.name = 'updated name';
        });
Forcing change detection: use the changeDetection
constructor(private cd: ChangeDetectorRef) {
    }

    ngAfterViewInit() {
        this.cd.detectChanges();
    }



No comments:

Post a Comment