Friday 17 August 2018

Generic error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'isLoading: [object Object]'. Current value: 'isLoading: true'

Error: Generic error:  ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'isLoading: [object Object]'. Current value: 'isLoading: true'

Resolution:

setTimeout the code that is setting the value. In my case, it was ngRX store dispatch action so I have changed action like below.

It was like below =>

public setProgress(isLoading: boolean) {
this.store.dispatch(new SetLaoding(isLoading));
}

I changed it to =>

public setProgress(isLoading: boolean) {
setTimeout(() => {
this.store.dispatch(new SetLaoding(isLoading));
});
}

and then this error resolved.